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 <vector>
#include <string>
#include <map>
#include <tuple>
#include <iostream>
#include <queue>
using namespace std;

typedef unsigned long long ull;


class RollingHash{
private:
	const ull B = 100000007;
	vector<ull>P;
	vector<ull>H;
	string s;
public:
	RollingHash(string _s){
		s = _s;
		P.push_back(1);
		H.push_back(0);
		for(int i=1;i<=s.size();i++){
			P.push_back(P[i-1] * B);
			H.push_back(H[i-1] * B + s[i-1]);
		}
	}
	ull Get(int l, int r){//l<=x<r
		return H[r] - H[l] * P[r-l];
	}
};

void Manachar(string s, vector<int>*r){
	(*r).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;
		(*r)[i] = j;
		int k = 1;
		while(i-k >= 0 && i+k < s.size() && k+(*r)[i-k]<j){
			(*r)[i+k]=(*r)[i-k];
			++k;
		}
		i += k;
		j -= k;
	}
}

string AddDollar(string s){
	string tmp = "$";
	for(int i=0;i<s.size();i++){
		tmp += s[i];
		tmp += "$";
	}
	return tmp;
}

int main(){
	
	string S;
	cin>>S;
	S = AddDollar(S);
	vector<int>S_Rad;
	Manachar(S, &S_Rad);
	RollingHash S_RH(S);
	map<ull, ull>S_Count;
	map<ull, int>S_Flg;
	priority_queue<tuple<int, int, int, ull> >S_Q;
	for(int i=0;i<S.size();i++){
		if(S_Rad[i]==1)continue;
 		ull h = S_RH.Get(i-S_Rad[i]+2, i+S_Rad[i]-1);
		S_Count[h]++;
		if(S_Flg[h])continue;
		S_Flg[h]=1;
		S_Q.push(make_tuple(S_Rad[i]-1,i-S_Rad[i]+2,i+S_Rad[i]-1,h));
	}
	
	while(!S_Q.empty()){
		int rad = get<0>(S_Q.top());
		int l = get<1>(S_Q.top());
		int r = get<2>(S_Q.top());
		ull h = get<3>(S_Q.top());
		S_Q.pop();
		if(rad<=2)break;
		l+=2;
		r-=2;
		ull nxt = S_RH.Get(l, r);
		S_Count[nxt]+=S_Count[h];
		if(S_Flg[nxt])continue;
		S_Flg[nxt]=1;
		S_Q.push(make_tuple(rad-2,l,r,nxt) );
	}
	
	string T;
	cin>>T;
	T = AddDollar(T);
	vector<int>T_Rad;
	Manachar(T, &T_Rad);
	RollingHash T_RH(T);
	map<ull, ull>T_Count;
	map<ull, int>T_Flg;
	priority_queue<tuple<int, int, int, ull> >T_Q;
	for(int i=0;i<T.size();i++){
		if(T_Rad[i]==1)continue;
 		ull h = T_RH.Get(i-T_Rad[i]+2, i+T_Rad[i]-1);
		T_Count[h]++;
		if(T_Flg[h])continue;
		T_Flg[h]=1;
		T_Q.push(make_tuple(T_Rad[i]-1,i-T_Rad[i]+2,i+T_Rad[i]-1,h));
	}
	
	ull sum = 0;
	
	while(!T_Q.empty()){
		int rad = get<0>(T_Q.top());
		int l = get<1>(T_Q.top());
		int r = get<2>(T_Q.top());
		ull h = get<3>(T_Q.top());
		T_Q.pop();
		if(S_Count.count(h)){
			sum += T_Count[h] * S_Count[h];
		}
		if(rad<=2)continue;
		l+=2;
		r-=2;
		ull nxt = T_RH.Get(l, r);
		T_Count[nxt]+=T_Count[h];
		if(T_Flg[nxt])continue;
		T_Flg[nxt]=1;
		T_Q.push(make_tuple(rad-2,l,r,nxt) );
	}
	
	cout<<sum<<endl;
	
	return 0;
}