#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 1000000
using namespace std;
ifstream fin ("pscpld.in");
ofstream fout ("pscpld.out");
pll mod = make_pair(100007, 100019);
ll lgput (ll a, ll b, ll m) {
if (b == 0) return 1;
if (b == 1) return a % m;
ll c = lgput(a, b/2, m); c = c*c%m;
if (b & 1) c = c*a%m;
return c;
}
pll adaug (pll h, char ch) {
h.fi = (h.fi * 26 + ch-'a') % mod.fi;
h.se = (h.se * 26 + ch-'a') % mod.se;
return h;
}
pll taie (pll h, int lh, pll t, int lt) {
h.fi = (h.fi - lgput(26, lh-lt, mod.fi)*t.fi%mod.fi + mod.fi) % mod.fi;
h.se = (h.se - lgput(26, lh-lt, mod.se)*t.se%mod.se + mod.se) % mod.se;
return h;
}
int n;
pll hp[maxn+5], hs[maxn+5];///hash prefix/sufix
string s;
int main () {
fin >> s;
n = sz(s); s = " "+s;
int i, j, z;
for (i = 1; i <= n; i++) hp[i] = adaug(hp[i-1], s[i]);
for (i = n; i >= 1; i--) hs[i] = adaug(hs[i+1], s[i]);
int pas, l, r, lg;
ll ans = 0;
pll h1, h2;
///pal par
for (i = 1; i <= n-1; i++) {
for (lg = 0, pas = (1<<21); pas > 0; pas /= 2) {
l = i-(lg+pas)+1;
r = i+1+(lg+pas)-1;
if (l >= 1 && r <= n) {
h1 = taie(hs[l], n-l+1, hs[i+1], n-i);
h2 = taie(hp[r], r, hp[i], i);
if (h1 == h2) lg += pas;
}
}
ans += 1LL*lg;
}
///pal impar
for (ans += 1LL*n, i = 2; i <= n-1; i++) {
for (lg = 0, pas = (1<<21); pas > 0; pas /= 2) {
l = i-(lg+pas);
r = i+(lg+pas);
if (l >= 1 && r <= n) {
h1 = taie(hs[l], n-l+1, hs[i], n-i+1);
h2 = taie(hp[r], r, hp[i], i);
if (h1 == h2) lg += pas;
}
}
ans += 1LL*lg;
}
fout << ans;
fin.close(); fout.close();
return 0;
}