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
문자열 전체에서 0의 개수와 1의 개수가 모두 이므로, 전체 문자열을 한 번에 삭제할 수 있다.
앞의 0 하나를 남기고 부분 문자열 0011을 삭제하면 단색 문자열 0이 된다.
번의 연산으로 단색 문자열을 만들 수 있으며, 번 이하로는 불가능하다.
처음부터 모든 문자가 0이므로 이미 단색 문자열이다.
해설
관리자가 작성한 해설을 별도 페이지에서 볼 수 있어요.