#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
long long int m = 0, n, res, k, ans = 0, nbcycle = 0;
string s2 = "zero", ch = "", s, t, s1 = "";
set<pair<long long int, long long int> > st;
vector<pair<string, long long int> > vm;
vector<pair<long long int, pair<long long int, long long int> > > vvv;
vector<pair<long long int, long long int> > vv, vv2;
vector<long long int> v[100005];
long long int dp[2005][2005], pal[2005][2005];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int i = 0, x, y, j = 0, q, mm = 0, mx = -1e9, idx = 0, ok = 0,
                l = 0, r = 0, negatif = 0, positif = 0, l1, r1, d;
  set<pair<long long int, long long int> >::iterator it, it1;
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    for (j = i; j >= 0; j--) {
      if (i == j)
        pal[i][j] = 1;
      else if (j == (i - 1) && s[i] == s[j])
        pal[j][i] = 1;
      else if (s[i] == s[j] && pal[j + 1][i - 1])
        pal[j][i] = 1;
    }
  }
  for (j = 0; j < n; j++) {
    for (i = j; i >= 0; i--) {
      if (i == j)
        dp[i][j] = 1;
      else {
        dp[i][j] = (pal[i][j] + dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1]);
      }
    }
  }
  res = 0;
  for (j = 0; j < n; j++) {
    for (i = j; i >= 0; i--) {
      if (pal[i][j] == 1) res += dp[j + 1][n - 1];
    }
  }
  cout << res;
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

You are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.

In a more formal way, you have to find the quantity of tuples (a, b, x, y) such that 1 ≤ a ≤ b < x ≤ y ≤ |s| and substrings s[a... b], s[x... y] are palindromes.

A palindrome is a string that can be read the same way from left to right and from right to left. For example, "abacaba", "z", "abba" are palindromes.

A substring s[i... j] (1 ≤ i ≤ j ≤ |s|) of string s = s1s2... s|s| is a string sisi + 1... sj. For example, substring s[2...4] of string s = "abacaba" equals "bac".

Input

The first line of input contains a non-empty string s which consists of lowercase letters ('a'...'z'), s contains at most 2000 characters.

Output

Output a single number — the quantity of pairs of non-overlapping palindromic substrings of s.

Please do not use the %lld format specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d format specifier.

Examples

Input

aa


Output

1


Input

aaa


Output

5


Input

abacaba


Output

36

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
long long int m = 0, n, res, k, ans = 0, nbcycle = 0;
string s2 = "zero", ch = "", s, t, s1 = "";
set<pair<long long int, long long int> > st;
vector<pair<string, long long int> > vm;
vector<pair<long long int, pair<long long int, long long int> > > vvv;
vector<pair<long long int, long long int> > vv, vv2;
vector<long long int> v[100005];
long long int dp[2005][2005], pal[2005][2005];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int i = 0, x, y, j = 0, q, mm = 0, mx = -1e9, idx = 0, ok = 0,
                l = 0, r = 0, negatif = 0, positif = 0, l1, r1, d;
  set<pair<long long int, long long int> >::iterator it, it1;
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    for (j = i; j >= 0; j--) {
      if (i == j)
        pal[i][j] = 1;
      else if (j == (i - 1) && s[i] == s[j])
        pal[j][i] = 1;
      else if (s[i] == s[j] && pal[j + 1][i - 1])
        pal[j][i] = 1;
    }
  }
  for (j = 0; j < n; j++) {
    for (i = j; i >= 0; i--) {
      if (i == j)
        dp[i][j] = 1;
      else {
        dp[i][j] = (pal[i][j] + dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1]);
      }
    }
  }
  res = 0;
  for (j = 0; j < n; j++) {
    for (i = j; i >= 0; i--) {
      if (pal[i][j] == 1) res += dp[j + 1][n - 1];
    }
  }
  cout << res;
  return 0;
}

```