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.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Solution_505_3 {

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        String st =in.readString();
        boolean arr[] = new boolean[st.length()];
        boolean temp[] = new boolean[st.length()];
        char c ='w';
        for (int i = 0; i < st.length(); i++) {
            if (st.charAt(i) == c) {
                arr[i] = true;
            }
        }

        int leftArr[] = new int[arr.length];
        int rightArr[] = new int[arr.length];
        int ans = 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(ans>=max){
                break;
            }
            ans = 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;
            int z =0;
            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);
                    z+=1;
                    int currentSum = leftVal + rightVal;
                    if (sum == null) {
                        sum = currentSum;
                        index = i;
                    } else {
                        if (sum < (currentSum)) {
                            sum = currentSum;
                            index = i;
                        }
                    }
                } else {
                    break;
                }
                if(z==-11){
                    z=0;
                }
            }
            if (index != null) {
                for (int i = 0; i < index; i++) {
                    temp[i] = arr[index - i - 1];
                }
                int ci = 0;
                for (int i = index; i < arr.length; i++) {
                    temp[i] = arr[arr.length - 1 - ci];
                    ci++;
                }
                for (int i = 0; i < arr.length; i++) {
                    arr[i] = temp[i];
                }
            } else {
                break;
            }
        }
        System.out.println(ans);
    }

    private static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
}