#include #include #include #include #include #include #include #include #include // complex a(1.2 , 2.3);// real(): 1.2, imag()2.3 using namespace std; #define MOD 1000000007 #define ll long long #define ld long double #define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++) #define rep(i,n) FOR(i,0,n) #define pb push_back #define mp make_pair #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end()) #define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;} template bool exist(vector vec, X item){return find(all(vec), item)!=vec.end();} vector ans; ll dp[10010]; void solve(string str){ if(str=="")return ; for(int i = 1;i<=str.size()/2;i++){ string a = str.substr(0,i); string b = str.substr(str.size()-i,i); if(a==b){ ans.pb(a); solve(str.substr(i,str.size()-i-i)); return; } } ans.pb(str); ans.pb(""); } int main(){ cin.tie(0); ios::sync_with_stdio(false); string S; cin >> S; solve(S); if(ans[ans.size()-1]==""){ ans.erase(ans.begin() + ans.size()-1); ll s = ans.size()-2; for(;s>=0;s--) ans.pb(ans[s]); } else{ ll s = ans.size()-1; for(;s>=0;s--) ans.pb(ans[s]); } ll result = ans.size()/2 + ans.size()%2; ll index = ans.size()/2; dp[0] = 1; for(ll i = 1; i<= ans.size()-1-index;i++){ for(ll m = index+1; m<= index+i;m++){ for(ll k = index;k<=m;k++){ string a = "", b= ""; for(ll n = k; n<= m;n++) a+= ans[n]; for(ll n = m; n>= k;n--) b+= ans[n]; if(a==b)dp[i]+=(dp[m-index-1]); } } } cout << dp[result-1] << endl; //cout << fixed << setprecision(16) << ans << endl; return 0; }