#include #include #include using namespace std; using ll = long long int; constexpr ll MOD = 1'000'000'007; vector Z_Algorithm(const string &s){ vector a(s.size()); a[0] = s.size(); int i = 1, j = 0; while(i < s.size()){ while(i+j < s.size() && s[j] == s[i+j]) ++j; a[i] = j; if(j == 0){ ++i; continue; } int k = 1; while(i+k < s.size() && k+a[k] < j){ a[i+k] = a[k], ++k; } i += k; j -= k; } return a; } struct Solver{ const string s; vector> mem; Solver(string &s): s(s), mem(vector>(s.size(), vector(s.size()))){ int l = s.size(); for(int i = 0; l-i*2 > 0; i++){ // cerr << s.substr(i, l-i*2) << endl; auto vec = Z_Algorithm(s.substr(i, l-i*2)); for(int j = 0; j < vec.size(); j++){ mem[i][i+j] = vec[j]; } } } ll f(int start, int end){ ll ans = 1; for(int i = 0; i+start < end-i; i++){ if(mem[start][end-i] == i+1){ ans += f(start+i+1, end-i-1); ans %= MOD; } } // for(int i = 0; i < s.size(); i++) cerr << mem[start][i] << " "; // cerr << endl; // cerr << start << " " << end << " " << ans << endl; return ans; } void solve(){ cout << f(0, s.size()-1) << endl; } }; int main(){ string s; cin >> s; Solver sol(s); sol.solve(); return 0; }