There is a self-driving taxi in Innopolis that drives on a long street. The street consists of
For the purpose of safety the self-driving taxi can only drive on the segments that are illuminated. In
other words, the taxi can drive from the stop
After breakdowns or repairs the street lamps can turn on or turn off. You are given the initial state of
the lamps at the moment
toggle i
— the -th lamp changes its state: if the lamp was on, it turns off, if the lamp was off, it turns on.query a b
— the head of the self-driving taxi department wonders, what is the total time in hours from up to the current time when the taxi was able to drive from stop to stop .
Help the head of self-driving taxi department to answer the questions.
Input
The first line contains two integers
The second line contains a string 1
if the 0
if the
Each of the following
toggle i
— the -th lamp changes its state.query a b
— calculate the number of hours until the current moment when the taxi was able to drive from stop to stop .
At least one of the events is query
.
Output
For each query event print a single integer: the answer to the question.
Scoring
Subtask 1 (points: 20)
Subtask 2 (points: 20)
For all query a b
events
Subtask 3 (points: 20)
For all toggle i
events the
Subtask 4 (points: 20)
All toggle events happen before all query events.
Subtask 5 (points: 20)
No additional constraint.
Sample Input
5 7
11011
query 1 2
query 1 2
query 1 6
query 3 4
toggle 3
query 3 4
query 1 6
Sample Output
1
2
0
0
1
2
Explanation
In the sample test:
Hour | Lamp states | Query | Answer |
---|---|---|---|
query 1 2 |
|||
query 1 2 |
|||
query 1 6 |
None | ||
query 3 4 |
None | ||
toggle 3 |
|||
query 3 4 |
|||
query 1 6 |
Comments
Since the original data were weak,
more tests cases were added to the last subtask, and the time limit was lowered from 
s to 
s.