Nijat had a string consisting of and . He had nothing to do and came up with such a game. Nijat can perform the following operations on the string:
Add to the left side and add to the right side;
Add to the right side and add to the left side;
You are given the remaining string after Nijat completes all operations (the number of performed operations can be ). Find the smallest possible initial length of the given string.
For example, from the string , you can obtain or .
The input consists of a string of length at most 10^5, composed of and .
Output the minimal length of the string Nijat initially had.
Example 1
Example 2