Problem B
Coffee Cup Combo
Jonna is a university student who attends
Some of the lecture halls have coffee machines, so Jonna can always make sure to get coffee there. Furthermore, when Jonna leaves a lecture hall, she can bring at most two coffee cups with her to the following lectures (one cup in each hand). But note that she cannot bring more than two coffee cups with her at any given time.
Given which of Jonna’s lectures have coffee machines, compute the maximum number of lectures during which Jonna can stay awake.
Input
The first line contains the integers
The second line contains a string
Output
Print one integer, the maximum number of lectures during which Jonna can stay awake.
Sample Input 1 | Sample Output 1 |
---|---|
10 0100010100 |
8 |
Sample Input 2 | Sample Output 2 |
---|---|
10 1100000000 |
4 |
Sample Input 3 | Sample Output 3 |
---|---|
1 0 |
0 |