#include <bits/stdc++.h>
const int MaxN = 3 * (100000 + 10);
using namespace std;
inline long long read() {
  long long cnt = 0, opt = 1;
  char ch = getchar();
  for (; !isalnum(ch); ch = getchar())
    if (ch == '-') opt = 0;
  for (; isalnum(ch); ch = getchar()) cnt = cnt * 10 + ch - 48;
  return opt ? cnt : -cnt;
}
char ch[MaxN], str[MaxN];
long long p[MaxN];
long long suf[MaxN], pre[MaxN];
long long sf[MaxN], pe[MaxN];
long long sum_pre[MaxN];
long long df_suf[MaxN], df_pre[MaxN];
long long len, ans, t;
inline void manacher() {
  long long mid = 0, Max_Right = 0;
  for (int i = 1; i <= len * 2 + 1; ++i) {
    if (Max_Right > i) p[i] = min(Max_Right - i, p[2 * mid - i]);
    while (str[i + p[i]] == str[i - p[i]]) ++p[i];
    if (i + p[i] > Max_Right) {
      Max_Right = i + p[i];
      mid = i;
    }
  }
}
int main() {
  while (scanf("%s", ch + 1) == 1) {
    ans = 0, t = 0;
    memset(p, 0, sizeof(p));
    memset(sf, 0, sizeof(sf));
    memset(pe, 0, sizeof(pe));
    memset(sum_pre, 0, sizeof(sum_pre));
    memset(df_suf, 0, sizeof(df_suf));
    memset(df_pre, 0, sizeof(df_pre));
    len = strlen(ch + 1);
    str[0] = '$';
    for (int i = 1; i <= len * 2 + 1; i += 2)
      str[i] = '#', str[i + 1] = ch[(i + 1) / 2];
    manacher();
    for (int i = 1; i <= 2 * len + 1; ++i) {
      if (str[i] == '#' && p[i] == 1)
        continue;
      else {
        df_suf[i]++, df_suf[i + p[i]]--;
        df_pre[i + 1]--, df_pre[i - p[i] + 1]++;
      }
    }
    for (int i = 1; i <= 2 * len + 1; ++i) {
      suf[i] = suf[i - 1] + df_suf[i], pre[i] = pre[i - 1] + df_pre[i];
      if (str[i] != '#') sf[++t] = suf[i], pe[t] = pre[i];
    }
    for (int i = t; i >= 1; --i) sum_pre[i] = sum_pre[i + 1] + pe[i];
    for (int i = 1; i <= t; ++i) ans += (long long)(sf[i] * sum_pre[i + 1]);
    printf("%lld\n", ans);
  }
  return 0;
}

### Prompt

In cpp, your task is to solve the following problem:

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>
const int MaxN = 3 * (100000 + 10);
using namespace std;
inline long long read() {
  long long cnt = 0, opt = 1;
  char ch = getchar();
  for (; !isalnum(ch); ch = getchar())
    if (ch == '-') opt = 0;
  for (; isalnum(ch); ch = getchar()) cnt = cnt * 10 + ch - 48;
  return opt ? cnt : -cnt;
}
char ch[MaxN], str[MaxN];
long long p[MaxN];
long long suf[MaxN], pre[MaxN];
long long sf[MaxN], pe[MaxN];
long long sum_pre[MaxN];
long long df_suf[MaxN], df_pre[MaxN];
long long len, ans, t;
inline void manacher() {
  long long mid = 0, Max_Right = 0;
  for (int i = 1; i <= len * 2 + 1; ++i) {
    if (Max_Right > i) p[i] = min(Max_Right - i, p[2 * mid - i]);
    while (str[i + p[i]] == str[i - p[i]]) ++p[i];
    if (i + p[i] > Max_Right) {
      Max_Right = i + p[i];
      mid = i;
    }
  }
}
int main() {
  while (scanf("%s", ch + 1) == 1) {
    ans = 0, t = 0;
    memset(p, 0, sizeof(p));
    memset(sf, 0, sizeof(sf));
    memset(pe, 0, sizeof(pe));
    memset(sum_pre, 0, sizeof(sum_pre));
    memset(df_suf, 0, sizeof(df_suf));
    memset(df_pre, 0, sizeof(df_pre));
    len = strlen(ch + 1);
    str[0] = '$';
    for (int i = 1; i <= len * 2 + 1; i += 2)
      str[i] = '#', str[i + 1] = ch[(i + 1) / 2];
    manacher();
    for (int i = 1; i <= 2 * len + 1; ++i) {
      if (str[i] == '#' && p[i] == 1)
        continue;
      else {
        df_suf[i]++, df_suf[i + p[i]]--;
        df_pre[i + 1]--, df_pre[i - p[i] + 1]++;
      }
    }
    for (int i = 1; i <= 2 * len + 1; ++i) {
      suf[i] = suf[i - 1] + df_suf[i], pre[i] = pre[i - 1] + df_pre[i];
      if (str[i] != '#') sf[++t] = suf[i], pe[t] = pre[i];
    }
    for (int i = t; i >= 1; --i) sum_pre[i] = sum_pre[i + 1] + pe[i];
    for (int i = 1; i <= t; ++i) ans += (long long)(sf[i] * sum_pre[i + 1]);
    printf("%lld\n", ans);
  }
  return 0;
}

```