#include #include #include #include #include #include #include using namespace std; typedef long long ll; vector v[5000], u[5000]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; string s; cin >> s; ll n = s.size(); set st; for(char c : s) st.insert(c); if(st.size() == 1) { ll ans = ((n-1)*(n-2)*(n-3))/6; cout << ans << endl; return 0; } for(int i = 0; i < n; i++){ for(int j = 0; i-j >= 0 && i+j < n; j++){ int l = i-j, r = i+j; if(s[l] != s[r]) break; v[l].push_back(r); u[r].push_back(l); } } for(int i = 0; i < n-1; i++){ for(int j = 0; i-j >= 0 && i+j+1 < n; j++){ int l = i-j, r = i+j+1; if(s[l] != s[r]) break; v[l].push_back(r); u[r].push_back(l); } } for(int i = 0; i < n; i++) { sort(v[i].begin(), v[i].end()); sort(u[i].begin(), u[i].end()); } ll ans = 0; for(int l : v[0]){ int l1 = l+1; int idx = 0; for(int r : u[n-1]){ if(r <= l) continue; auto p = upper_bound(v[l1].begin(), v[l1].end(), r-2); ans += p-v[l1].begin(); } } cout << ans << endl; }