#include using namespace std; #define int long long #define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define all(x) (x).begin(),(x).end() templatebool chmax(T &a,T b){if(abool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;} typedef pair pii; typedef vector vi; typedef vector vvi; const int inf = 1LL<<60; const int mod = 1e9 + 7; const double eps = 1e-9; /*{ }*/ template class RollingHash{ public: const int K = 2; int N; vector M, B; vector> hash, p; RollingHash(){} RollingHash(const string &s, vector b={107,311}){ init(s, b); } void init(const string &s, vector b={107, 311}, vector m={1000000007, 1000000009}){ M = m; B = b; hash.resize(K); p.resize(K); N = s.size(); for(int i = 0; i < K; i++){ hash[i].assign(N+1, 0); p[i].assign(N+1, 1); for(int j = 0; j < N; j++){ hash[i][j+1] = (hash[i][j]*B[i] + s[j])%M[i]; p[i][j+1] = p[i][j]*B[i]%M[i]; } } } void add(const string &s){ int m = s.size(); for(int i = 0; i < K; i++){ hash[i].resize(N+m+1, 0); p[i].resize(N+m+1, 1); for(int j = 0; j < m; j++){ hash[i][N+j+1] = (hash[i][N+j]*B[i] + s[j])%M[i]; p[i][N+j+1] = p[i][N+j]*B[i]%M[i]; } } N += m; } vector find(int l, int r){ vector res(K); for(int i = 0; i < K; i++){ T tmp = hash[i][r] + M[i] - hash[i][l]*p[i][r-l]%M[i]; res[i] = tmp >= M[i] ? tmp-M[i] : tmp; } return res; } }; int memo[10000]; bool vis[10000]; RollingHash rh; int dfs(int L, int R){ if(R < L) return 1; if(vis[L]) return memo[L]; int res = 1; int l = L, r = R; while(l < r){ if(rh.find(L, l+1) == rh.find(r, R+1)){ (res += dfs(l+1, r-1)) %= mod; } l++; r--; } vis[L] = true; return memo[L] = res; } signed main(){ srand((unsigned)time(NULL)); int B1 = rand()%10000+100000; int B2 = rand()%10000+500000; string s; cin >> s; int n = s.size(); rh.init(s, {B1, B2}); cout << dfs(0, n-1) << endl; return 0; }