#abc240h. [abc240_h]Sequence of Substrings
[abc240_h]Sequence of Substrings
Problem Statement
You are given a string of length consisting of 's and 's.
Find the maximum integer such that there is a sequence of pairs of integers $\\big((L_1, R_1), (L_2, R_2), \\ldots, (L_K, R_K)\\big)$ that satisfy all three conditions below.
- for each .
- for .
- The string is strictly lexicographically smaller than the string .
Constraints
- is an integer.
- is a string of length consisting of 's and 's.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
7
0101010
Sample Output 1
3
For , one sequence satisfying the conditition is $(L_1, R_1) = (1, 1), (L_2, R_2) = (3, 5), (L_3, R_3) = (6, 7)$. Indeed, is strictly lexicographically smaller than , and is strictly lexicographically smaller than .
For , there is no sequence $\\big((L_1, R_1), (L_2, R_2), \\ldots, (L_K, R_K)\\big)$ satisfying the condition.
Sample Input 2
30
000011001110101001011110001001
Sample Output 2
9