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 <algorithm>
#include <vector>
#include <functional>

using namespace std;

typedef long long ll;
const int Max=100005;
int par[100005],ran2[100005],a[100005],b[100005];
int sa[100005],lcp[100005],ran[100005],rad[200005],tmp[100005];
int n,k;
string S="",s1,s2;
ll res,cur;

void init()
{
	for(int i=0;i<100005;i++) par[i] = i;
	for(int i=0;i<100005;i++) ran2[i] = a[i] = b[i] = 0;
}

int find(int x)
{
	if(x == par[x]) return x;
	else return par[x] = find(par[x]);
}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);

	if(x == y) return;

	if(ran2[x] < ran2[y])swap(x,y);
		par[y] = x;
		cur += 1LL*a[x]*b[y]+1LL*a[y]*b[x];
		a[x] += a[y];
		b[x] += b[y];
		if(ran2[x] == ran2[y]) ran2[x]++;
}

bool same(int x,int y)
{
	return find(x) == find(y);
}

void add_a(int x)
{
	x = find(x);
	cur += b[x];
	a[x]++;
}

void add_b(int x)
{
	x = find(x);
	cur += a[x];
	b[x]++;
}

void manacher(){
	string s(n<<1|1,'#');
	for(int i=0;i<n;++i)s[i<<1|1]=S[i];
	for(int i=0,j=0,k=1;i<(n<<1|1);k=1){
		while(i>=j&&i+j<(n<<1|1)&&s[i-j]==s[i+j])++j;
		rad[i]=j;
		while(i>=k&&rad[i-k]<rad[i]-k)rad[i+k]=rad[i-k],++k;
		i+=k;j=max(j-k,0);
	}
}
int num[Max];
int wa[Max],wb[Max],wv[Max],wd[Max];
bool cmp(int *r,const int &a,const int &b,const int &l){
    return r[a]==r[b]&&r[a+l]==r[b+l];
}

void da(string r,const int &n,int m){
    int i,j,p,*x=wa,*y=wb,*t;
    for(i=0;i<m;i++)wd[i]=0;
    for(i=0;i<n;i++)wd[x[i]=r[i]] ++;
    for(i=1;i<m;i++)wd[i]+= wd[i-1];
    for(i=n-1;i>=0;i--)sa[-- wd[x[i]]]=i;
    for(j=1,p=1;p<n;j*=2,m=p){
        for(p=0,i=n-j;i<n;i++)y[p ++]=i;
        for(i=0;i<n;i++)if(sa[i]>=j)y[p ++] = sa[i] - j;
        for(i=0;i<n;i++)wv[i]=x[y[i]];
        for(i=0;i<m;i++)wd[i]=0;
        for(i=0;i<n;i++)wd[wv[i]]++;
        for(i=1;i<m;i++)wd[i]+=wd[i-1];
        for(i=n-1;i>=0;i--)sa[--wd[wv[i]]]=y[i];
        for(t=x,x=y,y=t,p=1,x[sa[0]]=0,i=1;i<n;i++)
            x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
    }
    for(int i=0;i<n;++i)ran[sa[i]]=i;
}


void construct_lcp()
{
	int h = 0;
	lcp[sa[0]] = 0;

	for(int i=0;i<n;i++)
	{
		int j = sa[ran[i]-1];
		if(h) h--;
		while(i+h < n && j+h < n && S[i+h] == S[j+h]) h++;
		lcp[ran[i]-1] = h;
	}
}
vector<int>query[100005];
vector<int>in[100005];

/*void Init(){
	cin>>s1>>s2;
	S=s1+"$"+s2;
	n=S.size();
	Init_SA();Init_LCP();
	manacher();
}

void Work(){
	Init();

}
int main(){Work();return 0;}*/
int main()
{
	cin >> s1 >> s2;
	S = s1+"$"+s2;
	n = S.size();
	da(S,n,128);
	construct_lcp();
	manacher();

	//odd
	cur = 0;
	init();
	for(int i=0;i<n;i++)
	{
		query[lcp[i]].push_back(i);
	}

	for(int i=0;i<n;i++)
	{
		int f = rad[i*2+1]-1;
		in[f].push_back(i);
	}
	int m = n;
	if(m%2==0)
	{
		m--;
	}
	for(int i=n;i>(m+1)/2;i--)
	{
		for(int j=0;j<query[i].size();j++)
		{
			unite(sa[query[i][j]],sa[query[i][j]+1]);
		}
	}
	for(int i=m;i>=1;i-=2)
	{
		for(int j=0;j<in[i].size();j++)
			if(in[i][j] < s1.size()) add_a(in[i][j]);
			else if(in[i][j] > s1.size()) add_b(in[i][j]);
		for(int j=0;j<query[(i+1)/2].size();j++)
		{
			unite(sa[query[(i+1)/2][j]],sa[query[(i+1)/2][j]+1]);
		}
		res += cur;
	}

	//even
	cur = 0;
	init();
	for(int i=0;i<100005;i++) in[i].clear();
	for(int i=0;i<=2*n;i+=2)
	{
		int f = rad[i]-1;
		in[f].push_back(i/2);
	}
	m = n;
	if(m%2==1)
	{
		m--;
	}
	for(int i=n;i>m/2;i--)
	{
		for(int j=0;j<query[i].size();j++)
		{
			unite(sa[query[i][j]],sa[query[i][j]+1]);
		}
	}
	for(int i=m;i>=2;i-=2)
	{
		for(int j=0;j<in[i].size();j++)
			if(in[i][j] < s1.size())  add_a(in[i][j]);
			else if(in[i][j] > s1.size()) add_b(in[i][j]);
		for(int j=0;j<query[i/2].size();j++)
		{
			unite(sa[query[i/2][j]],sa[query[i/2][j]+1]);
		}
		res += cur;
	}
	cout << res << endl;
}