You are given a binary string of length . A binary string is a string whose every character is either or .
In one operation, you may choose a non-empty contiguous substring of the current string such that the number of s in is equal to the number of s in , and delete it. After deletion, the remaining prefix and suffix are concatenated.
A string is called monochrome if it satisfies one of the following conditions.
- The string is empty.
- Every character of the string is .
- Every character of the string is .
Find the minimum number of operations required to make monochrome.
Input
The input is given in the following format.
Output
Print the minimum number of operations required to make monochrome.
Constraints
- .
- is a binary string of length .
Subtasks
Samples
Since the number of 0s and 1s in the entire string are both , the entire string can be deleted at once.
Leaving the first 0 and deleting the substring 0011 results in the monochromatic string 0.
A monochromatic string can be made with operations, and it can be proven that is it the optimal answer.
All characters are 0 from the beginning, so it is already a monochromatic string.