Gigatron needs to scale up and down. Given some requests to increase or decrease the number of pods, count the number of Gigatron pods running right now.
Gigatron is pegged to have a minimum of 1 running pod and a maximum of 1024 running pods. In the event a request would cause the number of pods to go outside of the limits, clamp it to either the minimum or maximum.
Constraints
Input Specification
The first line of input contains two integers and . There will be requests and Gigatron starts with running pods.
Each of the next lines is of the form INC x
or DEC x
.
If the line is of the INC x
, then the next request asks to increase the number of pods by .
If the line is of the DEC x
, then the next request asks to decrease the number of pods by .
Output Specification
After each request, print the number of running pods.
Sample Input
3 100
DEC 50
DEC 50
INC 2000
Sample Output
50
1
1024
Sample Explanation
The first request drops the number of pods to 50. The second request would drop the number of pods to 0, but that is not allowed and there is 1 running pod. The third request would increase the number of pods to 2001, but that is not allowed and there are only 1024 running pods.
Comments