// Problem: No.2606 Mirror Relay // Contest: yukicoder // URL: https://yukicoder.me/problems/no/2606 // Memory Limit: 512 MB // Time Limit: 2000 ms #include<bits/stdc++.h> #define debug(x) cerr<<(#x)<<" "<<(x)<<endl typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define pii pair<ll,ll> #define rep(i,a,b) for(ll i=(a);i<=(b);++i) #define per(i,a,b) for(ll i=(a);i>=(b);--i) using namespace std; bool Mbe; ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void write(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+'0'); } const ll N=1e6+9; ll n,p,q,fail[N],cnt[N],len[N],tot,lst,ch[N][26],pos[N],sum[N]; char s[N]; ll New(ll x){ len[++tot]=x; return tot; } ll Fail(ll x,ll i){ while(s[i-len[x]-1]!=s[i])x=fail[x]; return x; } bool Med; int main(){ cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n"; scanf("%s",s+1); n=strlen(s+1); reverse(s+1,s+n+1); s[0]=-1,fail[0]=1,lst=0; len[0]=0,len[1]=-1,tot=1; rep(i,1,n){ ll v=s[i]-'a'; p=Fail(lst,i); if(!ch[p][v]){ q=New(len[p]+2); fail[q]=ch[Fail(fail[p],i)][v]; ch[p][v]=q; } lst=ch[p][v]; ++cnt[lst]; pos[i]=lst; } per(i,tot,1)cnt[fail[i]]+=cnt[i]; rep(i,1,tot)sum[i]=cnt[i]*len[i]+sum[fail[i]]; write(*max_element(sum+1,sum+tot+1)); return 0; }