#include<bits/stdc++.h>#defineendl'\n'#definedeb(x) cout << #x <<" = "<< x <<'\n';#defineINF0x3f3f3f3fusingnamespace std;constint N =5e3+10;int f[N][N];voidsolve(){
string s;cin >> s;int ans =0;for(int len =2; len <= s.size(); len ++){for(int l =0; l + len -1< s.size(); l ++){int r = l + len -1;if(s[l]> s[r])
f[l][r]=1;elseif(s[l]== s[r])
f[l][r]= f[l +1][r -1];
ans += f[l][r];}}
cout << ans << endl;}signedmain(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);int t;
t =1;//cin >> t;while(t--)solve();}