using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { string inpt = Reader.ReadLine(); int ans = 0; for (int i = 0; i < inpt.Length; i++) { ans = Math.Max(ans, GetMaxTaisyo(i, inpt)); } Console.WriteLine(ans); } private int GetMaxTaisyo(int idx, String target) { int ans = 1; char[] tmp = target.ToArray(); for (int i = 1; i < target.Length; i++) { int fromIdx = idx - i; int toIdx = idx + i; if (fromIdx < 0) { break; } if(toIdx >= target.Length) { break; } if(tmp[idx-i]!=tmp[idx+i]) { tmp[idx - i] = ' '; tmp[idx + i] = ' '; } ans = Math.Max(ans, tmp.Skip(fromIdx).Take(i * 2 + 1).Count(a => a != ' ')); } tmp = target.ToArray(); for (int i = 1; i < target.Length; i++) { int fromidx = idx - i + 1; int toIdx = idx + i; if (fromidx < 0) { break; } if (toIdx >= target.Length) { break; } if(tmp[fromidx] != tmp[toIdx]) { tmp[fromidx] = ' '; tmp[toIdx] = ' '; } ans = Math.Max(ans, tmp.Skip(fromidx).Take(i * 2).Count(a => a != ' ')); } return ans; } public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 1145141919810 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }