Problem: 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.

Input

The only line contains a string s (1 ≤ |s| ≤ 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.

Output

Print a single integer — the maximum possible zebra length.

Examples

Input

bwwwbwwbw


Output

5


Input

bwwbwwb


Output

3

Note

In the first example one of the possible sequence of operations is bwwwbww|bw → w|wbwwwbwb → wbwbwwwbw, that gives the answer equal to 5.

In the second example no operation can increase the answer.

Solution (in JAVA):

Solution:

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class CopyOfMain {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		boolean arr[] = new boolean[str.length()];
		boolean temp[] = new boolean[str.length()];
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == 'w') {
				arr[i] = true;
			}
		}

		int leftArr[] = new int[arr.length];
		int rightArr[] = new int[arr.length];
		int answer = 1;
		for (int k = 0; k < arr.length; k++) {
			int max = 1;
			for (int i = 0; i < arr.length; i++) {
				if (i == 0) {
					leftArr[i] = 1;
				} else {
					if (arr[i] == arr[i - 1]) {
						leftArr[i] = 1;
					} else {
						leftArr[i] = leftArr[i - 1] + 1;
					}
				}
				max = Math.max(max, leftArr[i]);
			}
			if(answer>=max){
				break;
			}
			answer = max;
			for (int i = arr.length - 1; i >= 0; i--) {
				if (i == arr.length - 1) {
					rightArr[i] = 1;
				} else {
					if (arr[i] == arr[i + 1]) {
						rightArr[i] = 1;
					} else {
						rightArr[i] = rightArr[i + 1] + 1;
					}
				}
			}

			Integer sum = null;
			Integer index = null;
			for (int i = 1; i < arr.length; i++) {
				if (arr[0] != arr[arr.length - 1]) {
					int leftVal = Math.min(rightArr[0], i);
					int rightVal = Math.min(leftArr[arr.length - 1], arr.length
							- i);
					int currentSum = leftVal + rightVal;
					if (sum == null) {
						sum = currentSum;
						index = i;
					} else {
						if (sum < (currentSum)) {
							sum = currentSum;
							index = i;
						}
					}
				} else {
					break;
				}
			}
			if (index != null) {
				for (int i = 0; i < index; i++) {
					temp[i] = arr[index - i - 1];
				}
				int c = 0;
				for (int i = index; i < arr.length; i++) {
					temp[i] = arr[arr.length - 1 - c];
					c++;
				}
				for (int i = 0; i < arr.length; i++) {
					arr[i] = temp[i];
				}
			} else {
				break;
			}
		}
		System.out.println(answer);
	}
}
// bbwbwwbwbwbwbw