#include #include #include #include using namespace std; const long long mod = 1e9 + 7; int dp[5050]; int lcp[5050][5050]; void to(int &x, int y) { x += y; if (x >= mod) { x -= mod; } } int main() { string s; cin >> s; const int n = s.size(); dp[0] = 1; for (int i = (n - 1) / 2; i >= 0; i--) { for (int j = n - 1; j >= n / 2; j--) { if (s[i] == s[j]) { lcp[i][j - n / 2] = lcp[i + 1][j - n / 2 + 1] + 1; } else { lcp[i][j - n / 2] = 0; } } } for (int i = 0; i * 2 < n; i++) { for (int j = i; j * 2 < n; j++) { // s[i..j] == s[n-1-j..n-1-i] if (lcp[i][n - 1 - j - n / 2] >= j - i + 1) { to(dp[j + 1], dp[i]); } } } int ans = 0; for (int i = 0; i < (n + 2) / 2; i++) { to(ans, dp[i]); } cout << ans << endl; }