Plasticine zebra

题意翻译

给你一个长度为 $\left|s\right|$ 的01串 $s$,每次操作你可以任选一个 $k$ ,使01串的 $[1,k]$ 和 $(k,\left|s\right|]$ 分别翻转(其中一个区间可以为空),求经过任意次操作后能得到的最长的01交替出现的子串的长度。(实际题目中01用w和b代替)

题目描述

Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now wants to select several consequent (contiguous) pieces of alternating colors to create a zebra. Let's call the number of selected pieces the length of the zebra. Before assembling the zebra Grisha can make the following operation $ 0 $ or more times. He splits the sequence in some place into two parts, then reverses each of them and sticks them together again. For example, if Grisha has pieces in the order "bwbbw" (here 'b' denotes a black strip, and 'w' denotes a white strip), then he can split the sequence as bw|bbw (here the vertical bar represents the cut), reverse both parts and obtain "wbwbb". Determine the maximum possible length of the zebra that Grisha can produce.

输入输出格式

输入格式


The only line contains a string $ s $ ( $ 1 \le |s| \le 10^5 $ , where $ |s| $ denotes the length of the string $ s $ ) comprised of lowercase English letters 'b' and 'w' only, where 'w' denotes a white piece and 'b' denotes a black piece.

输出格式


Print a single integer — the maximum possible zebra length.

输入输出样例

输入样例 #1

bwwwbwwbw

输出样例 #1

5

输入样例 #2

bwwbwwb

输出样例 #2

3

说明

In the first example one of the possible sequence of operations is bwwwbww|bw $ \to $ w|wbwwwbwb $ \to $ wbwbwwwbw, that gives the answer equal to $ 5 $ . In the second example no operation can increase the answer.