import java.io.*; import java.util.*; public class Main_yukicoder588 { private static Scanner sc; private static Printer pr; private static void solve() { char[] s = sc.next().toCharArray(); int n = s.length; int max = 0; for (int i = 0; i < n; i++) { int tmp = 1; for (int j = 1; i - j >= 0 && i + j < n; j++) { if (s[i - j] == s[i + j]) { tmp += 2; } } max = Math.max(max, tmp); } for (int i = 0; i < n; i++) { int tmp = 0; for (int j = 0; i - j >= 0 && i + 1 + j < n; j++) { if (s[i - j] == s[i + 1 + j]) { tmp += 2; } } max = Math.max(max, tmp); } pr.println(max); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }