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==i+1: ANS=max(ANS,DP[i][j]*2) else: ANS=max(ANS,DP[i][j]*2+1) print(ANS)