using System; namespace Palindrome01 { class MainClass { static void Main(string[] args) { string sentence; int maxLength = 0; sentence = Console.ReadLine(); for (int i = 0; i < sentence.Length - 1; i++) { for (int j = i; j < sentence.Length; j++) { string temp = sentence.Substring(i, sentence.Length - j); int num = SearchPalidrome(temp, 0); if (num == sentence.Length) num -= 2; if (num > maxLength) maxLength = num; } } Console.WriteLine(maxLength); } static int SearchPalidrome(string sentence, int layer) { if (sentence.Length == 1) return ++layer; if (sentence.Length == 0) return layer; if (sentence[0] == sentence[sentence.Length - 1]) { string temp = sentence.Substring(1, sentence.Length - 2); return SearchPalidrome(temp, layer+=2); } return 0; } } }