#include <bits/stdc++.h>
using namespace std;
const int N = 2e3;
int id[N + 2], ix[N + 2];
struct eertree {
  int sz, last, palCnt[N + 2];
  struct node {
    int next[26], len, link;
  } pal[N + 2];
  void constructor(void) {
    memset(pal, 0, sizeof(pal));
    memset(palCnt, 0, sizeof(palCnt));
    pal[0].len = -1, pal[0].link = 0;
    pal[1].len = 0, pal[1].link = 0;
    sz = 1, last = 1;
  }
  void build(string s) {
    s = "#" + s;
    for (int p = 1; p < s.size(); p++) {
      while (s[p - pal[last].len - 1] != s[p]) last = pal[last].link;
      int x = pal[last].link, c = s[p] - 'a';
      while (s[p - pal[x].len - 1] != s[p]) x = pal[x].link;
      if (!pal[last].next[c]) {
        pal[last].next[c] = ++sz;
        pal[sz].len = pal[last].len + 2;
        if (pal[sz].len == 1)
          pal[sz].link = 1;
        else
          pal[sz].link = pal[x].next[c];
        palCnt[sz] = 1 + palCnt[pal[sz].link];
        id[p] = palCnt[sz];
      } else
        id[p] = palCnt[pal[last].next[c]];
      last = pal[last].next[c];
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  eertree er;
  er.constructor();
  er.build(s);
  for (int i = 1; i <= s.size(); i++) ix[i] = id[i];
  reverse(s.begin(), s.end());
  er.constructor();
  er.build(s);
  for (int i = 2; i <= s.size(); i++) id[i] += id[i - 1];
  long long ans = 0;
  for (int i = 1; i <= s.size(); i++) ans += (1LL * ix[i] * id[s.size() - i]);
  cout << ans << endl;
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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;
const int N = 2e3;
int id[N + 2], ix[N + 2];
struct eertree {
  int sz, last, palCnt[N + 2];
  struct node {
    int next[26], len, link;
  } pal[N + 2];
  void constructor(void) {
    memset(pal, 0, sizeof(pal));
    memset(palCnt, 0, sizeof(palCnt));
    pal[0].len = -1, pal[0].link = 0;
    pal[1].len = 0, pal[1].link = 0;
    sz = 1, last = 1;
  }
  void build(string s) {
    s = "#" + s;
    for (int p = 1; p < s.size(); p++) {
      while (s[p - pal[last].len - 1] != s[p]) last = pal[last].link;
      int x = pal[last].link, c = s[p] - 'a';
      while (s[p - pal[x].len - 1] != s[p]) x = pal[x].link;
      if (!pal[last].next[c]) {
        pal[last].next[c] = ++sz;
        pal[sz].len = pal[last].len + 2;
        if (pal[sz].len == 1)
          pal[sz].link = 1;
        else
          pal[sz].link = pal[x].next[c];
        palCnt[sz] = 1 + palCnt[pal[sz].link];
        id[p] = palCnt[sz];
      } else
        id[p] = palCnt[pal[last].next[c]];
      last = pal[last].next[c];
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  eertree er;
  er.constructor();
  er.build(s);
  for (int i = 1; i <= s.size(); i++) ix[i] = id[i];
  reverse(s.begin(), s.end());
  er.constructor();
  er.build(s);
  for (int i = 2; i <= s.size(); i++) id[i] += id[i - 1];
  long long ans = 0;
  for (int i = 1; i <= s.size(); i++) ans += (1LL * ix[i] * id[s.size() - i]);
  cout << ans << endl;
  return 0;
}

```