#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "../Library/debug.h"
#else
#define dbg(x...)
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto &a : x)
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
const char nl = '\n';
const int INF = 1e9;
const ll MOD = 1e9 + 7;
struct state{
int len, link;
int cnt;
map<char, int> next;
};
const int mxN = 3e5+50;
state st[mxN+2];
int sz, last;
string s;
void eertree_init(){
st[0].link=1; st[1].len=-1;
st[0].len=0; st[1].link=0;
last=0; sz=2;
s.pb('\0');
}
void append(char c){
s.pb(c);
while(s[sz(s) - st[last].len - 2] != c)
last = st[last].link;
if(!st[last].next.count(c)){
st[sz].len=st[last].len+2;
st[sz].link=st[last].link;
while(s[sz(s) - st[st[sz].link].len - 2]!= c)
st[sz].link = st[st[sz].link].link;
st[sz].link = st[st[sz].link].next[c];
st[last].next[c] = sz++;
}
last = st[last].next[c];
st[last].cnt++;
}
void solve() {
string a;
cin>>a;
eertree_init();
trav(i,a){
append(i);
}
vi cnt(sz), order(sz);
FOR(i,2,sz) cnt[st[i].len]++;
FOR(i,1,sz) cnt[i]+=cnt[i-1];
// dbg(order);
FORd(i,2,sz) order[--cnt[st[i].len]]=i;
// dbg(order);
// vi tmp; F0R(i,sz) tmp.pb(st[i].cnt); dbg(tmp);
F0Rd(i,sz-2)
st[st[order[i]].link].cnt += st[order[i]].cnt;
ll mx=0;
FOR(i,2,sz){
mx = max(mx, 1LL * st[i].cnt * st[i].len);
}
cout<<mx<<nl;
// tmp.clear(); F0R(i,sz) tmp.pb(st[i].cnt); dbg(tmp);
// tmp.clear(); F0R(i,sz) tmp.pb(st[i].link); dbg(tmp);
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int TC = 1;
// cin >> TC;
while (TC--) {
solve();
}
return 0;
}