← 返回题目列表

Codeforces · 1025/C

C. 橡皮泥斑马

中文机器翻译题面 查看原题

在辛苦工作了一周之后,还有什么比去动物园更好的吗? 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.

在组装斑马Grisha之前,可以进行以下操作$$$0$$$或多次。他将序列中的某个地方分成两部分,然后将它们颠倒过来,然后再次将它们粘在一起。 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.

输入

唯一一行包含字符串 $$$s$$$($$$1 \le |s| \le 10^5$$$,其中 $$$|s|$$$ 表示字符串 $$$s$$$ 的长度),仅由小写英文字母 'b' 和 'w' 组成,其中 'w' 表示白色块,'b' 表示黑色块。

输出

Print a single integer — the maximum possible zebra length.

示例

输入 #1

bwwwbwwbw

输出 #1

5

输入 #2

bwwbwwb

输出 #2

3

注意

在第一个示例中,可能的操作序列之一是 bwwwbww|bw $$$\to$$$ w|wbwwwbwb $$$\to$$$ wbwbwwwbw,其给出的答案等于 $$$5$$$。

在第二个示例中,没有任何操作可以增加答案。