import sys input = sys.stdin.readline S=input().strip() DP=[[0]*(len(S)+3) for i in range(len(S)+3)] for i in range(len(S)): for j in range(len(S)-1,i,-1): DP[i][j]=max(DP[i][j],DP[i-1][j+1]) if S[i]==S[j]: DP[i][j]+=1 ANS=0 for i in range(len(S)): for j in range(i+1,len(S)): if j%2==i%2: ANS=max(ANS,DP[i][j]*2+1) else: ANS=max(ANS,DP[i][j]*2) print(ANS)