Problem: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.

Today's practice is to improve the ability to read messages hidden from sentences by searching for palindromes in strings. There may be many palindromes, so I'd like to count the number while searching.

Given two strings S and T, we want to find the number of pairs of integers (i, j, k, l) that satisfy the following:

* 1 ≤ i ≤ j ≤ (length of S).
* 1 ≤ k ≤ l ≤ (length of T).
* The substrings extracted from the i-th to j-th characters of S are the same as the substrings extracted from the k-th to l-th characters of T, and these are palindromes (even when read from the left). It is a character string that is the same even when read from the right).



Input


S
T


Both the strings S and T have a length of 1 or more and 50,000 or less, and consist of uppercase letters.

Output

Output the number of pairs of integers (i, j, k, l) that satisfy the condition on one line.

Examples

Input

ICPC
CPCPC


Output

10


Input

BABBAB
ABBA


Output

14


Input

MYON
USAGI


Output

0

Solution (in CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define maxn 200007
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n, al;
P d[maxn], lcp[maxn];
char s[maxn];
void manacher() {
  int l = 1, r = 0;
  for (int i = 1; i <= n; i++) {
    d[i] = mp((i > r) ? 1 : min(r - i + 1, d[l + r - i].first), i);
    while (i - d[i].first >= 1 && i + d[i].first <= n 
           && s[i - d[i].first] == s[i + d[i].first]) 
      d[i].first++;
    if (i + d[i].first - 1 > r) {
      r = i + d[i].first - 1;
      l = i - d[i].first + 1;
    }
  }
}
namespace SA {
  int m, k, sa[maxn], rk[maxn << 1], cnt[maxn], id[maxn], tmp[maxn];
  void work() {
    m = 'Z';
    for (int i = 1; i <= n; i++) cnt[rk[i] = s[i]]++;
    for (int i = 1; i <= m; i++) cnt[i] += cnt[i - 1];
    for (int i = n; i >= 1; i--) sa[cnt[rk[i]]--] = i;
    m = 0;
    for (int i = 1; i <= n; i++) {
      if (rk[sa[i]] == rk[sa[i - 1]]) tmp[sa[i]] = m;
      else tmp[sa[i]] = ++m;
    }
    memcpy(rk, tmp, sizeof(tmp));
    for (int w = 1; m < n; w <<= 1) {
      k = 0;
      for (int i = n; i > n - w; i--) id[++k] = i;
      for (int i = 1; i <= n; i++) if (sa[i] > w) id[++k] = sa[i] - w;
      memset(cnt, 0, sizeof(cnt));
      for (int i = 1; i <= n; i++) cnt[lcp[i].first = rk[id[i]]]++;
      for (int i = 1; i <= m; i++) cnt[i] += cnt[i - 1];
      for (int i = n; i >= 1; i--) sa[cnt[lcp[i].first]--] = id[i];
      m = 0;
      for (int i = 1; i <= n; i++) {
        if (rk[sa[i]] == rk[sa[i - 1]] && rk[sa[i] + w] == rk[sa[i - 1] + w]) {
          tmp[sa[i]] = m;
        } else {
          tmp[sa[i]] = ++m;
        }
      }
      memcpy(rk, tmp, sizeof(tmp));
    }
    k = 0;
    for (int i = 1; i <= n; i++) {
      if (k) k--;
      while (s[i + k] == s[sa[rk[i] - 1] + k]) k++;
      lcp[rk[i]] = mp(k, rk[i]);
    }
  }
}
ll cur, ans;
namespace uf {
  int par[maxn], numa[maxn], numb[maxn];
  void init(int n) {
    for (int i = 1; i <= n; i++) par[i] = i;
  }
  int fin(int u) {
    if (par[u] == u) return u;
    return par[u] = fin(par[u]);
  }
  void uni(int u, int v) {
    u = fin(u), v = fin(v);
    if (u == v) return;
    par[u] = v;
    cur -= (ll)numa[u] * numb[u];
    cur -= (ll)numa[v] * numb[v];
    numa[v] += numa[u], numb[v] += numb[u];
    cur += (ll)numa[v] * numb[v];
  }
  void adda(int u) {
    u = fin(u);
    numa[u]++;
    cur += numb[u];
  }
  void addb(int u) {
    u = fin(u);
    numb[u]++;
    cur += numa[u];
  }
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  s[++n] = '$';
  al = n << 1;
  scanf("%s", s + n + 1);
  n = strlen(s + 1) * 2 + 1;
  for (int i = n; i >= 1; i--) {
    if (i & 1) s[i] = '#';
    else s[i] = s[i >> 1];
  }
  manacher();
  SA::work();
  sort(d + 1, d + n + 1, greater<P>());
  sort(lcp + 1, lcp + n + 1, greater<P>());
  int dk = 1, lcpk = 1;
  uf::init(n);
  for (int i = n; i >= 1; i--) {
    while (dk <= n && d[dk].first == i) {
      int pos = d[dk].second;
      if (pos <= al) uf::adda(SA::rk[pos]);
      else uf::addb(SA::rk[pos]);
      dk++;
    }
    while (lcpk <= n && lcp[lcpk].first == i) {
      uf::uni(lcp[lcpk].second, lcp[lcpk].second - 1);
      lcpk++;
    }
    ans += cur;
  }
  (ans -= (ll)al * (n - al + 1) / 4) /= 2;
  printf("%lld\n", ans); 
  return 0;
}