import java.util.Scanner;

public class Main {
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] charArray = sc.nextLine().toCharArray();
        int maxLength = charArray.length == 0 ? 0 : 1;
        for (int i = 0; i < charArray.length; i++) {
            maxLength = judgeSymmetry(charArray, i, maxLength);
        }
        System.out.println(maxLength);
    }

    /**
     * 判断当前字符是否时奇数对称或者偶数对称
     * @param charArray
     * @param currentCharIndex
     * @param maxLength
     * @return
     */
    private static int judgeSymmetry(char[] charArray, int currentCharIndex, int maxLength) {
        int preCharIndex = currentCharIndex - 1;
        int sufCharIndex = currentCharIndex + 1;
        if (preCharIndex < 0 || sufCharIndex >= charArray.length) {
            return maxLength;
        }
        // 偶数对称逻辑
        if (charArray[currentCharIndex] == charArray[sufCharIndex]) {
            int evenLength = 2;
            evenLength = judgeSymmetry(charArray, preCharIndex, evenLength, sufCharIndex + 1);
            maxLength = Math.max(maxLength, evenLength);
        }
        
        // 奇数对称逻辑(这里不能二选一,需要注意既是偶数对称又是奇数对称的情况)
        if (charArray[preCharIndex] == charArray[sufCharIndex]) {
            int oddLength = 3;
            oddLength = judgeSymmetry(charArray, preCharIndex - 1, oddLength, sufCharIndex + 1);
            maxLength = Math.max(maxLength, oddLength);
        }
        return maxLength;
    }

    /**
     * 判断前后两个字符是否一致
     * @param charArray
     * @param preCharIndex
     * @param evenLength
     * @param sufCharIndex
     * @return
     */
    private static int judgeSymmetry(char[] charArray, int preCharIndex, int evenLength, int sufCharIndex) {
        if (preCharIndex < 0 || sufCharIndex >= charArray.length || charArray[preCharIndex] != charArray[sufCharIndex]) {
            return evenLength;
        }
        evenLength += 2;
        return judgeSymmetry(charArray, preCharIndex - 1, evenLength, sufCharIndex + 1);
    }
}