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.*;
import java.util.*;

public class Question {
	public static int MOD = 1000000007;

	static Scan scn = new Scan();
	static Print printer = new Print();

	public static void main(String[] args) throws Exception {

		C();
		printer.close();
	}

	public static void A() throws Exception {

		int len = scn.scanInt();
		String str = scn.scanString();

		if (len == 1) {
			printer.printLine("Yes");
			return;
		}

		int[] hash = new int[26];

		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			hash[ch - 'a']++;
		}

		for (int i = 0; i < hash.length; i++) {
			if (hash[i] > 1) {
				printer.printLine("Yes");
				return;
			}
		}

		printer.printLine("No");

	}

	public static void B() throws Exception {

		int n = scn.scanInt();
		IntIntPair[] arr = new IntIntPair[n];

		IntIntPair minPair = new IntIntPair(Integer.MAX_VALUE, Integer.MAX_VALUE);

		for (int i = 0; i < n; i++) {
			arr[i] = new IntIntPair(scn.scanInt(), scn.scanInt());

			if (arr[i].compareTo(minPair) < 0)
				minPair = arr[i];
		}

		HashSet<Integer> candidates = new HashSet<>();
		getAllUniquePrimeFactors(minPair.one, candidates);
		getAllUniquePrimeFactors(minPair.two, candidates);

		for (int i = 0; i < arr.length; i++) {

			HashSet<Integer> hs = new HashSet<>();
			for (int factor : candidates) {
				if (arr[i].one % factor == 0 || arr[i].two % factor == 0)
					hs.add(factor);
			}

			if (hs.size() == 0) {
				printer.printLine("-1");
				return;
			}

			candidates = hs;

		}

		printer.print(candidates.toArray()[0].toString());

	}

	public static void C() throws Exception {

		String str = scn.scanString();

		boolean oneFlip = str.charAt(0) != str.charAt(str.length() - 1);

		int maxLen = 1;
		int temp = 1;
		boolean isf = true;
		int fr = 0, bk = 0;

		for (int i = 1; i < str.length(); i++) {
			char ch = str.charAt(i);
			char pch = str.charAt(i - 1);

			if (ch != pch) {
				temp++;
			} else {
				if (isf) {
					fr = maxLen;
					isf = false;
				}

				temp = 1;
			}

			if (temp > maxLen)
				maxLen = temp;
		}
		bk = temp;

		if (maxLen == str.length()) {
			printer.print(maxLen + "");
			return;
		}

		if (oneFlip && (fr + bk > maxLen))
			maxLen = fr + bk;

		printer.print(maxLen + "");

	}

	public static class IntIntPair implements Comparable<IntIntPair> {

		int one;
		int two;

		public IntIntPair(int one, int two) {
			this.one = one;
			this.two = two;
		}

		@Override
		public int compareTo(IntIntPair o) {
			// TODO Auto-generated method stub
			int val = this.one - o.one;
			if (val != 0)
				return val;

			return this.two - o.two;
		}
	}

	public static void getAllUniquePrimeFactors(int num, HashSet<Integer> hs) {

		while (num % 2 == 0) {
			hs.add(2);
			num /= 2;
		}

		for (int fac = 3; fac <= Math.sqrt(num); fac += 2) {

			if (fac > num)
				break;

			if (num % fac == 0) {
				hs.add(fac);

				while (num % fac == 0)
					num /= fac;
			}
		}

		if (num > 2)
			hs.add(num);

	}

	static class Scan {
		private InputStream in;
		private byte[] buf = new byte[1024 * 1024];
		private int index;
		private int total;

		public Scan() {
			// this.in = in;
			in = System.in;
			// try {
			// in = new FileInputStream(new File("/home/ujjwal/test/test"));
			// } catch (Exception ex) {
			//
			// }
		}

		public int scan() throws IOException {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				total = in.read(buf);
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public int[] inputArray(int n) throws Exception {
			int[] arr = new int[n];

			for (int i = 0; i < n; i++) {
				arr[i] = scn.scanInt();
			}

			return arr;
		}

		public ArrayList<Integer> inputList(int n) throws Exception {

			ArrayList<Integer> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				list.add(scn.scanInt());
			}

			return list;
		}

		public int[][] inputMatrix(int n, int m) throws Exception {
			int[][] arr = new int[n][m];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					arr[i][j] = scn.scanInt();
				}
			}

			return arr;
		}

		public int scanInt() throws IOException {
			int integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public long scanLong() throws IOException {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() throws IOException {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}

	static class Print {
		private final BufferedWriter bw;

		public Print() {
			bw = new BufferedWriter(new OutputStreamWriter(System.out));
		}

		public void print(String str) throws IOException {
			bw.append(str);
		}

		public void printArray(int[] arr) throws Exception {

			for (int i = 0; i < arr.length; i++) {
				printer.print(arr[i] + " ");
			}

			printer.printLine("");
		}

		public void printList(ArrayList<Integer> list) throws Exception {

			for (int i = 0; i < list.size(); i++) {
				printer.print(list.get(i) + " ");
			}

			printer.printLine("");
		}

		public void printLine(String str) throws IOException {
			print(str);
			bw.append("\n");
		}

		public void close() throws IOException {
			bw.close();
		}
	}

}