#CCC25J2. Donut Shop
Donut Shop
Problem Description
The owner of a donut shop spends the day baking and selling donuts. Given the events that happen over the course of the day, your job is to determine the number of donuts remaining when the shop closes.
Input Specification
- The first line contains a non-negative integer
D
, representing the number of donuts available when the shop opens. - The second line contains a positive integer
E
, representing the number of events that happen during the day. - The next
E
pairs of lines describe the events:- Each pair starts with a symbol (
+
for baking,-
for selling). - The next line contains an integer
Q
, the quantity of donuts for that event.
- Each pair starts with a symbol (
Output Specification
Output the number of donuts remaining when the shop closes.
Sample Input
10
3
+
24
-
6
-
12
Sample Output
16