#include <bits/stdc++.h>   using namespace std;   long long n, a[3000], b[3000], w[500], pos[500][5000], ans;   string second;   int ispal(int x, int y) {     int t = y;     while (x != y) {       if (second[x] != second[y]) return 0;       if (y - x == 1 || y - x == 2) {         b[t]++;         return 1;       }       x++, y--;     }   }   int main() {     cin >> second;     for (int i = second.size() - 1; i >= 0; i--) {       a[i] = a[i + 1] + 1;       for (int j = 0; j < w[second[i] - 97]; j++) {         a[i] += ispal(i, pos[second[i] - 97][j]);       }       pos[second[i] - 97][w[second[i] - 97]] = i;       w[second[i] - 97]++;     }     for (int i = 0; i < second.size() - 1; i++) {       b[i]++;       ans += b[i] * a[i + 1];     }     cout << ans;     return 0;   }   