|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||12||0||0||0.000%|
Our local car park needs your help. They have a fixed number of spaces for parking and want to be able to tell drivers who are approaching the park just how many spaces are available to use. They also need to stop the entry barrier from opening if the park is full. If your system works, they will sell it to other car park owners.
Input consits of a number of scenarios, each one representing a different car park. The first line consists of two integers, S and C (10 <= S <= 500, 0 <= C <= S). S is the number of spaces in the car park overall, and C is the number of cars currently parked there. The last scenario contains 0 0 – this scenario should not be processed.
The second line of each scenario consists of a string of up to 255 characters, each character being one of the upper case letters I or O. This string represents a stream of data from the entry and exit barriers. I means that a car has attempted to come in to the car park, O that a car has driven out. If the car park is not full, a car attempting to enter will be allowed in and counted. If all the spaces in the car park are filled with cars, a car attempting to enter will be refused entry and not counted. (Such a car may try again later).
If there are no cars in the car park, an O in the data stream at that point represents an error, and processing of that scenario should stop.
Output consists of a single line for each scenario. If there has been an error in the data stream, it will contain just the word error. Otherwise, it will be a single integer representing the number of cars in the car park at the end of the scenario.
50 12 IIOIOOIOIIIOOIOIOOII 25 3 IOOIOOOOIIO 0 0