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 C {
	private static Reader reader = new Reader();
	private static PrintWriter writer = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {
		String s = reader.readString();
		int n = s.length();
		int ans = 0;
		for (int i = 0; i < n; ) {
			int j = i;
			while (j + 1 < n && match(s.charAt(j), s.charAt(j + 1))) {
				j++;
			}
			ans = Math.max(ans, j - i + 1);
			i = j + 1;
		}
		if (ans == n) {
			writer.println(n);
			writer.close();
			return;
		}
		writer.println(Math.max(ans, go(s.toCharArray())));
		reader.close();
		writer.close();
	}
	
	private static boolean match(char a, char b) {
		return (a == 'b' && b == 'w') || (a == 'w' && b == 'b');
	}
	
	private static int go(char[] arr) {
		int n = arr.length;
		int l = 0; 
		int r = n - 1;
		if (match(arr[l], arr[r])) {
			while (l + 1 < n && match(arr[l], arr[l + 1])) {
				l++;
			}
			while (r > 0 && match(arr[r], arr[r - 1])) {
				r--;
			}
			if (l == n || r == 0) {
				return n;
			}
			int len = (l + 1) + ((n - 1) - r + 1);
			int ifGo = Math.max(go(op(arr, l)), go(op(arr, r - 1)));
			return Math.max(len, ifGo);
		}
		return 0;
	}
	
	private static char[] op(char[] a, int cutId) {
		int n = a.length;
		if (cutId == n - 1) {
			return a;
		}
		char[] b = new char[n];
		int id = 0;
		int l = cutId;
		while (l >= 0) {
			b[id++] = a[l--];
		}
		int r = n - 1;
		while (r > cutId) {
			b[id++] = a[r--];
		}
		return b;
	}

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream input;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			this(System.in);
		}

		public Reader(String fileName) throws FileNotFoundException {
			this(new FileInputStream(fileName));
		}

		public Reader(InputStream inputStream) {
			input = new DataInputStream(inputStream);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readString() throws IOException {
			byte c = read();
			while (c <= ' ') {
				c = read();
			}
			StringBuilder string = new StringBuilder();
			do {
				if (Character.isValidCodePoint(c)) {
					string.appendCodePoint(c);
				}
				c = read();
			} while (!isWhitespace(c));
			return string.toString();
		}

		public int readInt() throws IOException {
			int result = 0;
			byte c = read();
			while (c <= ' ') {
				c = read();
			}
			boolean isNegative = (c == '-');
			if (isNegative) {
				c = read();
			}
			do {
				result = result * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (isNegative) {
				return -result;
			}
			return result;
		}

		public long readLong() throws IOException {
			long result = 0;
			byte c = read();
			while (c <= ' ') {
				c = read();
			}
			boolean isNegative = (c == '-');
			if (isNegative) {
				c = read();
			}
			do {
				result = result * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (isNegative) {
				return -result;
			}
			return result;
		}

		public double readDouble() throws IOException {
			double result = 0, div = 1;
			byte c = read();
			while (c <= ' ') {
				c = read();
			}
			boolean isNegative = (c == '-');
			if (isNegative) {
				c = read();
			}
			do {
				result = result * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					result += (c - '0') / (div *= 10);
				}
			}
			if (isNegative) {
				return -result;
			}
			return result;
		}

		private boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private void fillBuffer() throws IOException {
			bytesRead = input.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead) {
				fillBuffer();
			}
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (input == null) {
				return;
			}
			input.close();
		}

	}

}