#include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; const ll MOD = 1e9+7LL; ll dp[10005]; // 文字列S[i:sz-i]を回文かい分解する組み合わせ数 bool checked[10005]; vector z[10005]; vector ZAlgorithm(const string& S) { int sz = S.size(); vector ret(sz); ret[0] = sz; int i = 1, j = 0; while (i < sz) { while (i+j < sz && S[j] == S[i+j]) j++; ret[i] = j; if (j == 0) { i++; continue; } int k = 1; while (i+k < sz && k+ret[k] < j) ret[i+k] = ret[k], k++; i += k; j -= k; } return ret; } ll rec(int l, int r) { if (r < l) return 1; if (checked[l]) return dp[l]; ll ret = 1; int left = l, right = r; while (left < right) { if (z[l][right - l] == left - l + 1) (ret += rec(left+1, right-1)) %= MOD; left++; right--; } checked[l] = true; return dp[l] = ret; } int main() { string S; cin >> S; int sz = S.size(); for (int i = 0; i * 2 < sz; i++) { z[i] = ZAlgorithm(S.substr(i, sz - i * 2)); } cout << rec(0, sz-1) << "\n"; return 0; }