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;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
const int INFLL=1001001001001001001ll;
const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}


struct PalindromicTree{
    struct node{
    map<char,int>nex;
        int len,suflink,height,firapp,cnt;
        //length,suffix link,height,first appearance
    };

    string s;
    vector<node>v;
    vector<int>ord;
    int n,suf;

    bool process(int pos){
        char ch=s[pos];
        int cur=suf;
        while(true){
            if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch)break;
            cur=v[cur].suflink;
        }

        if(v[cur].nex.count(ch)){
            suf=v[cur].nex[ch];
            v[suf].cnt++;
            return false;
        }

        suf=n++;

        v[suf].len=v[cur].len+2;
        v[suf].firapp=pos;
        v[suf].cnt=1;
        v[cur].nex[ch]=suf;

        if(v[suf].len==1){
            v[suf].suflink=1;
            v[suf].height=1;
            return true;
        }

        while(true){
            cur=v[cur].suflink;
            if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch){
                v[suf].suflink=v[cur].nex[ch];
                break;
            }
        }
        v[suf].height=1+v[v[suf].suflink].height;
        return true;
    }

    void init(const string &s){
        this->s=s;
        v.clear();
        v.resize(s.size()+10);

        n=2;
        suf=1;
        v[0].firapp=v[1].firapp=-1;
        v[0].len=-1;
        v[1].len=0;
        v[0].suflink=v[1].suflink=0;
        v[0].height=v[1].height=0;
    }

    void calcOrd(){
        ord={0,1};
        for(int i=0;i<ord.size();i++){
            for(auto &p:v[ord[i]].nex)ord.pb(p.se);
        }
    }

    void calcCnt(){
        assert(ord.size());
        for(int i=ord.size()-1;i>=0;i--){
            v[v[ord[i]].suflink].cnt+=v[ord[i]].cnt;
        }
        v[0].cnt=v[1].cnt=0;
    }
};

int dps[1111111],dpt[1111111];

signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    string S,T;
    cin>>S>>T;

    string ST=S+"@*"+T;
    PalindromicTree pt;pt.init(ST);
    for(int i=0;i<ST.size();i++){
        pt.process(i);
        if(i<S.size())dps[pt.suf]++;
        else if(i>S.size())dpt[pt.suf]++;

    }


    int ans=0;
    for(int i=pt.n-1;i>=2;i--){
        ans+=dps[i]*dpt[i];
        dps[pt.v[i].suflink]+=dps[i];
        dpt[pt.v[i].suflink]+=dpt[i];
    }

    cout<<ans<<endl;
    return 0;
}