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;

typedef long long ll;
typedef unsigned long long ull;

const ull P = 1000000007ULL;

string s[2];
set<ull> inv;
vector<int> p;
vector<ull> h;
vector<ull> pmod;
map<ull, ull> pre;
map<ull, ull> has[2];
map<ull, vector<ull>> nxt;

ull geth(int k, int d, int r)
{	
	int lt = d - r + 1;
	int rt = d + r - 1;
	
	return h[rt + 1] - h[lt]*pmod[rt - lt + 1];
}

void getsubstr(int k, ull v)
{
	for (auto t : nxt[v])
	{
		getsubstr(k, t);
		has[k][v] += has[k][t];
	}
}

void prework(const int k)
{
	/*---< prepare >---*/
	
	p.clear();
	h.clear();
	pre.clear();
	nxt.clear();
	
	string str; 
	cin >> str;
	
	s[k] += '$';
	
	for (auto c : str)
	{
		s[k] += c;
		s[k] += '#';
	}
	
	int len = s[k].length();
	
	p.resize(len + 5);
	h.resize(len + 5);
	pmod.resize(len + 5);
	
	/*---< manacher >---*/
	
	int ma = -1, id = -1;	
	for (int i = 0; i < len; ++i)
	{
		if (i <= ma)
			p[i] = min(
				ma - i + 1,
				p[2*id - i]
			);
		else p[i] = 1;
		
		while (
			s[k][i - p[i]]
		==	s[k][i + p[i]]
		)++p[i];
		
		if (ma < i + p[i] - 1)
			ma = i + p[i] - 1, id = i;
	}
	
	/*-----< hash >-----*/
	
	for (int i = 0; i < len; ++i)
		h[i + 1] = h[i]*P + s[k][i];
		
	pmod[0] = 1;
	for (int i = 1; i <= len; ++i)
		pmod[i] = pmod[i - 1]*P;
		
	/*----< build >----*/
	
	for (int i = 0; i < len; ++i)
	{
		int r = p[i];
		ull v = geth(k, i, r);
		
		bool flag = true;
		
		while (!has[k].count(v))
		{			
			has[k][v];
			
			if (flag)++has[k][v], flag = false;
			
			if (s[k][i + r - 1] == '#')
				inv.insert(v);
				
			if (s[k][i - r + 1] == '$')
				inv.insert(v);
			
			if (--r == 0)break;
			
			ull n = geth(k, i, r);
			
			pre[v] = n;
			nxt[n].push_back(v);
			
			v = n;
		}
		
		if (flag)++has[k][v];
	}
	
	for (auto it : has[k])
		if (!pre.count(it.first))
			getsubstr(k, it.first);
}

signed main(void)
{
	prework(0);
	prework(1);
	
	ull answer = 0;
	
	for (auto it : has[0])
		if (!inv.count(it.first))
			answer += it.second * has[1][it.first];
			
	cout << answer << endl;
}