Problem Likelihood


Problem Statement

You are given a length nn string s=s1s2...sns = s_1 s_2 ... s_n such that ss is a binary string (all characters are either 00 or 11). The string represents some information about the problems on your favourite problem solving site YeetCode.

For some character in ss there are two cases:

  • if si=1s_i = 1 then that means the ithi^{th} YeetCode problem is a premium problem.
  • if si=0s_i = 0 then that means the ithi^{th} YeetCode problem is not a premium problem (a non-premium problem).

Since you are poor, you do not have access to YeetCode premium, however, the people at YeetCode have coded it so that if you click the Random Problem\text{Random Problem} button, instead of only getting YeetCode non-premium problems, they put you on any random problem (uniformly distributed). When this happens, if you are on problem ii, you will click the Next Problem\text{Next Problem} button and go to the next problem (problem i+1i + 1) until you get to a non-premium problem. If you press the Next Problem\text{Next Problem} button and you are problem nn, you will go to problem 11.

You would like to determine the non-premium problem with which you have the most likelihood of ending on after going through this process. If there are multiple with the same highest probability, then choose the one with the smallest problem number.

Input Format

Your only line of input should contain a string of length nn representing ss.

Output Format

Your only line of output should contain the problem you are most likely to end on,

Constraints

  • 1≤n≤1051 \leq n \leq 10^5
  • si=0s_i = 0 or si=1s_i = 1
  • ss will contain at least one 00

Sample Cases

Input 1
1110110
Output 1
4
Input 2
1011011
Output 2
2
Input 3
01110001011101000111
Output 3
1

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.