#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; bool p[5001][5001]; ll dp[5001][5]; int main(){ ios::sync_with_stdio(false); cin.tie(0); string S; cin >> S; int n = sz(S); for(int sl = 0; sl < n; ++sl)for(int sr = sl; sr < min(n, sl + 2); sr++) { for(int l = sl, r = sr; l >= 0 && r < n; --l, ++r) { if(S[l] != S[r])break; p[l][r + 1] = 1; } } dp[0][0] = 1; rep(i, n)rep(j, 4) { for(int ni = i + 1; ni <= n; ++ni)if(j == 2 || p[i][ni])dp[ni][j + 1] += dp[i][j]; } cout << dp[n][4] << endl; }