S = input() N = len(S) ans = 0 def isPalindrome(p): s,t,c = 0,len(p) - 1,0 while s < t and p[s] == p[t]: s,t,c= s + 1,t - 1,c + 2 if s == t and p[s] == p[t]: c += 1 return c == len(p) def palindrome(p): n = len(p) if n == 1: return True for i in range(n - 1): for j in range(i + 1,n): if isPalindrome(p[i:j + 1]): return True return False def dfs(n,m): if n == N: return 0 ret = 0 for i in range(n,N if m >= 1 else N - 1): if isPalindrome(S[n:i + 1]) and palindrome(S[i::]): d = dfs(i + 1,m + 1) ret = max(i + 1 - n,ret) ret = max(ret,d) return ret print(dfs(0,0))