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<bits/stdc++.h>

using namespace std;

struct Manachan
{
  vector< int > radius;

  void build(const string &s)
  {
    radius.resize(s.size());

    int i = 0, j = 0;
    while(i < s.size()) {
      while(i - j >= 0 && i + j < s.size() && s[i - j] == s[i + j]) {
        ++j;
      }
      radius[i] = j;
      int k = 1;
      while(i - k >= 0 && i + k < s.size() && k + radius[i - k] < j) {
        radius[i + k] = radius[i - k];
        ++k;
      }
      i += k;
      j -= k;
    }
  }

  int operator[](const int k) const
  {
    return (radius[k]);
  }

  size_t size()
  {
    return (radius.size());
  }
};

const int _base = 1e9 + 7;

struct RollingHash
{
  vector< unsigned long long > hashed, power;

  RollingHash(const string &s)
  {
    int sz = s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);

    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = power[i] * _base;
    }
    for(int i = 0; i < sz; i++) {
      hashed[i + 1] = (hashed[i] + s[i]) * _base;
    }
  }

  unsigned long long get(int l, int r) // [l, r)
  {
    return ((hashed[r] - hashed[l] * power[r - l]));
  }
};

int main()
{
  string S, T;
  cin >> S >> T;

  string A[2];
  A[0] += S[0], A[1] += T[0];
  for(int i = 1; i < S.size(); i++) A[0] += "$", A[0] += S[i];
  for(int i = 1; i < T.size(); i++) A[1] += "$", A[1] += T[i];

  Manachan latte[2];
  latte[0].build(A[0]), latte[1].build(A[1]);

  priority_queue< tuple< int, int, int > > que;
  map< unsigned long long, int > sz[2];
  RollingHash hash[2] = {RollingHash(A[0]), RollingHash(A[1])};

  auto gethash = [&](int idx, int center, int length)
  {
    return (hash[idx].get(center - length + 1, center + length));
  };

  for(int z = 0; z < 2; z++) {
    for(int i = 0; i < latte[z].size(); i++) {
      if(sz[z][gethash(z, i, latte[z][i])]++ == 0) {
        que.emplace(latte[z][i], i, z);
      }
    }
  }

  long long ret = 0;

  while(!que.empty()) {
    int length, center, idx;
    tie(length, center, idx) = que.top();
    que.pop();

    auto hash1 = gethash(idx, center, length);

    if(A[idx][center - length + 1] != '$' && idx == 0) {
      ret += 1LL * sz[0][hash1] * sz[1][hash1];
    }

    if(length > 1) {
      auto hash2 = gethash(idx, center, length - 1);
      if(!sz[idx].count(hash2)) que.emplace(length - 1, center, idx);
      sz[idx][hash2] += sz[idx][hash1];
    }
  }

  cout << ret << endl;
}