This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) (x).bg(), (x).ed()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define FRN(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define FSN(i, n) for (int (i) = (n) - 1; (i) >= 0; --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
    END OF TEMPLATE
----------------------------------------------------------------
    Tran The Bao - ghostwriter
    Training for VOI23 gold medal
----------------------------------------------------------------
    DIT ME CHUYEN BAO LOC
----------------------------------------------------------------
*/
const pi M = {1e9 + 7, 1e9 + 9};
const pi base = {37, 127};
const int N = 3e5 + 5;
int n, d[N];
str s;
pi p[N], h[N], h1[N];
vpi v, v1;
ll rs = 0;
vi adj[N];
pi geth(const int &l, const int &r) {
	pi ans;
	ans.st = (h[r].st - 1LL * h[l - 1].st * p[r - l + 1].st % M.st + M.st) % M.st;
	ans.nd = (h[r].nd - 1LL * h[l - 1].nd * p[r - l + 1].nd % M.nd + M.nd) % M.nd;
	return ans;
}
pi geth1(const int &l, const int &r) {
	pi ans;
	ans.st = (h1[l].st - 1LL * h1[r + 1].st * p[r - l + 1].st % M.st + M.st) % M.st;
	ans.nd = (h1[l].nd - 1LL * h1[r + 1].nd * p[r - l + 1].nd % M.nd + M.nd) % M.nd;
	return ans;
}
bool cmp(const pi &a, const pi &b) { return a.nd - a.st + 1 < b.nd - b.st + 1; }
int getpos(const pi &x) { if (x > v1.bk()) return -1; int ans = lb(all(v1), x) - v1.bg(); if (v1[ans] != x) return -1; return ans; }
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
    p[0] = {1, 1};
    FOR(i, 1, N - 1) {
    	p[i].st = 1LL * p[i - 1].st * base.st % M.st;
    	p[i].nd = 1LL * p[i - 1].nd * base.nd % M.nd;
    }
    cin >> s;
    n = sz(s);
    s = "#" + s + "#";
    FOR(i, 1, n) {
    	h[i].st = (1LL * h[i - 1].st * base.st % M.st + s[i] - 'a' + 1) % M.st;
    	h[i].nd = (1LL * h[i - 1].nd * base.nd % M.nd + s[i] - 'a' + 1) % M.nd;
    }
    FOS(i, n, 1) {
    	h1[i].st = (1LL * h1[i + 1].st * base.st % M.st + s[i] - 'a' + 1) % M.st;
    	h1[i].nd = (1LL * h1[i + 1].nd * base.nd % M.nd + s[i] - 'a' + 1) % M.nd;
    }
    FOR(i, 1, n) {
    	int l = 1, r = min(i - 1, n - i), ans = 0;
    	WHILE(l <= r) {
    		int mid = l + (r - l) / 2;
    		if (geth(i - mid, i + mid) == geth1(i - mid, i + mid)) {
    			ans = mid;
    			l = mid + 1;
    		}
    		else r = mid - 1;
    	}
    	v.pb({i - ans, i + ans});
    }
    FOR(i, 1, n - 1) {
    	if (s[i] != s[i + 1]) continue;
    	int l = 1, r = min(i - 1, n - i - 1), ans = 0;
    	WHILE(l <= r) {
    		int mid = l + (r - l) / 2;
    		if (geth(i - mid, i + 1 + mid) == geth1(i - mid, i + 1 + mid)) {
    			ans = mid;
    			l = mid + 1;
    		}
    		else r = mid - 1;
    	}
    	v.pb({i - ans, i + 1 + ans});
    }
    sort(all(v), cmp);
    EACH(i, v) v1.pb(geth(i.st, i.nd));
    FSN(i, sz(v)) {
    	int ln = v[i].st, rn = v[i].nd, len = rn - ln + 1;
    	pi curh = geth(ln, rn);
    	int posh = getpos(curh);
    	++d[posh];
    	if (d[posh]) {
	    	FOR(j, 1, 26) {
	    		pi tmp = curh;
	    		tmp.st = (1LL * j * p[len + 1].st % M.st + 1LL * tmp.st * base.st % M.st + j) % M.st;
	    		tmp.nd = (1LL * j * p[len + 1].nd % M.nd + 1LL * tmp.nd * base.nd % M.nd + j) % M.nd;
	    		int pos1 = getpos(tmp);
	    		if (pos1 != -1) d[posh] = max(d[posh], 1 + d[pos1]);
	    	}
    	}
    	rs = max(rs, 1LL * len * d[posh]);
    }
    cout << rs;
    return 0;
}
/*
----------------------------------------------------------------
From Benq:
    stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * DON'T GET STUCK ON ONE APPROACH
----------------------------------------------------------------
*/
Compilation message (stderr)
palindrome.cpp: In function 'int main()':
palindrome.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
palindrome.cpp:79:5: note: in expansion of macro 'FOR'
   79 |     FOR(i, 1, N - 1) {
      |     ^~~
palindrome.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
palindrome.cpp:86:5: note: in expansion of macro 'FOR'
   86 |     FOR(i, 1, n) {
      |     ^~~
palindrome.cpp:33:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   33 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
palindrome.cpp:90:5: note: in expansion of macro 'FOS'
   90 |     FOS(i, n, 1) {
      |     ^~~
palindrome.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
palindrome.cpp:94:5: note: in expansion of macro 'FOR'
   94 |     FOR(i, 1, n) {
      |     ^~~
palindrome.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
palindrome.cpp:106:5: note: in expansion of macro 'FOR'
  106 |     FOR(i, 1, n - 1) {
      |     ^~~
palindrome.cpp:36:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   36 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
palindrome.cpp:120:5: note: in expansion of macro 'EACH'
  120 |     EACH(i, v) v1.pb(geth(i.st, i.nd));
      |     ^~~~
palindrome.cpp:35:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   35 | #define FSN(i, n) for (int (i) = (n) - 1; (i) >= 0; --(i))
      |                            ^
palindrome.cpp:121:5: note: in expansion of macro 'FSN'
  121 |     FSN(i, sz(v)) {
      |     ^~~
palindrome.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
palindrome.cpp:127:7: note: in expansion of macro 'FOR'
  127 |       FOR(j, 1, 26) {
      |       ^~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |