#include #define ls(k) k << 1 #define rs(k) k << 1 | 1 #define fi first #define se second #define add(x, y) ((x + y >= mod) ? (x + y - mod) : (x + y)) #define dec(x, y) ((x - y < 0) ? (x - y + mod) : (x - y)) #define popcnt(x) __builtin_popcount(x) #define open(s1, s2) freopen(s1, "r", stdin), freopen(s2, "w", stdout); using namespace std; typedef __int128 __; typedef long double lb; typedef double db; typedef unsigned long long ull; typedef long long ll; bool Begin; const int N = 5050; const ull base = 127; inline ll read(){ ll x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){ if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void write(ll x){ if(x < 0){ putchar('-'); x = -x; } if(x > 9) write(x / 10); putchar(x % 10 + '0'); } ll ans; int n; int a[N]; ull poww[N], p[2][N]; char s[N], t[N]; inline ull get(int l, int r, bool f){ return p[f][r] - poww[r - l + 1] * p[f][l - 1]; } inline bool check(int l, int r){ return get(l, r, 0) == get(n - r + 1, n - l + 1, 1); } bool End; int main(){ //open("par.in", "par.out"); poww[0] = 1; scanf("%s", s + 1); n = strlen(s + 1); for(int i = 1; i <= n; ++i){ t[i] = s[n - i + 1]; poww[i] = base * poww[i - 1]; p[0][i] = p[0][i - 1] * base + s[i]; p[1][i] = p[1][i - 1] * base + t[i]; } for(int i = 1; i <= n; ++i) for(int j = 1; j < i; ++j) if(check(1, j) && check(j + 1, i)) ++a[i]; for(int l = 2; l < n; ++l) for(int r = l; r < n; ++r) if(check(r + 1, n)) ans += a[l - 1]; write(ans); //cerr << '\n' << abs(&Begin - &End) / 1048576 << "MB"; return 0; }