#include using namespace std; using ll = long long; const int M = 998244353, M2 = 1e9 + 7; ll h1[500005], h2[500005]; ll rh1[500005], rh2[500005]; int n; ll qpow(ll x, ll n, ll M){ ll ret = 1; while(n){ if(n & 1) ret = ret * x % M; x = x * x % M; n >>= 1; } return ret; } bool checkhui(int L, int R){ if(L == R) return 1; ll hx = (h1[R] - h1[L - 1] + M) * qpow(26, 1LL * (L - 1) * (M - 2), M) % M; ll hy = (h2[R] - h2[L - 1] + M2) * qpow(26, 1LL * (L - 1) * (M2 - 2), M2) % M2; ll rhx = (rh1[L] - rh1[R + 1] + M) * qpow(26, 1LL * (n - R) * (M - 2), M) % M; ll rhy = (rh2[L] - rh2[R + 1] + M2) * qpow(26, 1LL * (n - R) * (M2 - 2), M2) % M2; return hx == rhx && hy == rhy; } int main(){ string s; cin >> s; n = s.size(); ll p1 = 1, p2 = 1; for(int i = 0; i < n; i++, p1 = p1 * 26 % M, p2 = p2 * 26 % M2){ h1[i + 1] = (h1[i] + p1 * (s[i] - 'a')) % M; h2[i + 1] = (h2[i] + p2 * (s[i] - 'a')) % M2; } p1 = 1, p2 = 1; for(int i = n; i >= 1; i--, p1 = p1 * 26 % M, p2 = p2 * 26 % M2){ rh1[i] = (rh1[i + 1] + p1 * (s[i - 1] - 'a')) % M; rh2[i] = (rh2[i + 1] + p2 * (s[i - 1] - 'a')) % M2; } ll ans = 0; for(int i = 1; i + 3 <= n; i++){ if(!checkhui(1, i)) continue; for(int j = i + 1; j + 2 <= n; j++){ if(!checkhui(i + 1, j)) continue; for(int k = j + 2; k <= n; k++){ if(!checkhui(k, n)) continue; // cout << i << ' ' << j << ' ' << k << endl; ++ans; } } } cout << ans << endl; return 0; }