#include #define int ll #define fi first #define endl '\n' #define il inline #define se second #define pb push_back #define INF 0x3f3f3f3f using namespace std; typedef long long ll; typedef pair pii; #ifdef ONLINE_JUDGE #define debug(...) 0 #else #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #endif const int N = 1e4 + 10; string s, str; int ans, p[N << 1], r = -1, c = -1, suf[N]; signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); freopen("par.in", "r", stdin); freopen("par.out", "w", stdout); cin >> s, str = "~#"; for (int i = 0; i < s.size(); i++) str += s[i], str += '#'; str += '$'; for (int i = 1; i < str.size(); i++) { p[i] = (i < r) ? min(p[2 * c - i], r - i) : 1; while (str[i - p[i]] == str[i + p[i]]) p[i]++; if (r < i + p[i]) r = i + p[i], c = i; } int n = s.size(); s = ' ' + s; for (int i = n; i >= 1; i--) suf[i] = suf[i + 1] + (p[i + n] - 1 >= n - i + 1); for (int i = 1; i <= n - 3; i++) { if (p[i + 1] - 1 < i) continue; for (int j = i + 1; j <= n - 2; j++) ans += suf[j + 2] * (p[2 * i + j - i + 1] - 1 >= j - i); } cout << ans << endl; return 0; }