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>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef unsigned long long ll;
ll B=1e9+7;
ll invB=13499267949257065399ULL;
int S[100000];
ll hs[100001];
map<ll,ll> has;		//has->num
map<ll,ll> D,E;
map<ll,ll> nxt;
map<ll,vector<ll> > prv;
set<ll> doll;	//$..$
void Manacher(string s){
	int i=0,j=0;
	while(i<s.size()){
		while(i-j>=0&&i+j<s.size()&&s[i-j]==s[i+j]) ++j;
		S[i]=j;
		int k=1;
		while(i-k>=0&&i+k<s.size()&&k+S[i-k]<j) S[i+k]=S[i-k],++k;
		i+=k,j-=k;
	}
}
ll ex(ll x,ll p){
	ll a=1;
	while(p){
		if(p%2) a*=x;
		x*=x;
		p/=2;
	}
	return a;
}
ll H(int x,int y){	//[x,y)
	return hs[y]-hs[x]*ex(B,y-x);
}
void dfs(ll h){
	for(ll x:prv[h]){
		dfs(x);
		has[h]+=has[x];
	}
}
void solve(){
	string s,s_;
	cin>>s_;
	int N=s_.size();
	s=s_[0];
	rep1(i,N-1) s+="$",s+=s_[i];
	N=s.size();
	Manacher(s);
	rep(i,N) hs[i+1]=hs[i]*B+s[i];
	rep(i,N){
		int x=S[i];
		ll h=H(i-x+1,i+x);
		bool fst=1;
		while(!has.count(h)){
			if(fst) has[h]++,fst=0;
			has[h];		//access
			if(s[i-x+1]=='$') doll.insert(h);
			x--;
			if(x==0) break;
			ll nh=H(i-x+1,i+x);
			nxt[h]=nh;
			prv[nh].pb(h);
			h=nh;
		}
		if(fst) has[h]++;
	}
	for(auto p:has){
		ll h=p.fs;
		if(!nxt.count(h)) dfs(h);
	}
}
int main(){
	solve();
	D=has;
	rep(i,100000) S[i]=0;
	rep(i,100001) hs[i]=0;
	has.clear();
	nxt.clear();
	prv.clear();
	solve();
	E=has;
	ll ans=0;
/*	for(auto p:E){
		ll h=p.fs;
		show(h);
		show(E[h]);
	}*/
	for(auto p:D){
		ll h=p.fs;
		if(doll.count(h)) continue;
		if(E.count(h)){
			ans+=D[h]*E[h];
		}
	}
	cout<<ans<<endl;
}