Akie wants to visit Earth once and hopes to get her travel expenses reimbursed. However, it is said that she can only get reimbursed after solving the following problem. Can you help her travel for free?
A string is called a "free string" if and only if it consists only of W and B and no two adjacent characters are the same.
Now, you are given a string $$$s$$$ of length $$$n$$$ consisting only of W and B. You can perform at most one operation: choose a substring $$$s_{l,r}$$$ ($$$1 \leq l \leq r \leq n$$$),and replace it with a "free string" of the original length.
What is the minimum length of the substring you need to choose to turn the entire string into a "free string"? If no operation is needed, output $$$0$$$.
The only line contains a string consisting of W and B of length $$$n$$$. It is guaranteed that $$$1 \leq n \leq 2 \times 10^5$$$.
An integer representing the answer.
WBBBBBW
3
BBWW
2
In the first example, you can select the substring $$$s_{3,5}$$$ and replace it with WBW.
In the second example, you can select the substring $$$s_{2,3}$$$ and replace it with WB.
| Name |
|---|


