#include #define INF 1145141919 #define INF_LL 114514191981036 using LL = long long int; using ULL = unsigned long long int; #define II pair using namespace std; string S; const LL mod = 1000000007; const int MAX_S = 10005; LL dp[MAX_S][MAX_S]; ULL Hash[MAX_S]; ULL BaseB[MAX_S]; ULL Base = 1000000000000009; void reg() { BaseB[0] = 1; for (size_t i = 0; i < S.length(); i++) { Hash[i+1] = Hash[i] * Base; Hash[i+1] += S[i]; BaseB[i+1] = BaseB[i] * Base; } } ULL calc(int l, int r) { return Hash[r] - Hash[l] * BaseB[r-l]; } LL solve(int l, int r) { if(dp[l][r] != -1) { return dp[l][r]; } LL ret = 1; for (size_t i = 1; l+i < r-i; i++) { if(calc(l, l+i) == calc(r-i, r)) { ret += solve(l+i, r-i); ret %= mod; } } return dp[l][r] = ret; } int main() { cin >> S; memset(dp, -1, sizeof(dp)); reg(); cout << solve(0, S.length()) << endl; return 0; }