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;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

std::string insert_doll(std::string const& s) {
    string res;
    for(int i = 0; i < (int)s.size(); ++i) {
        res += "$";
        res += s[i];
    }
    res += "$";
    return res;
}

std::vector<int> manacher(std::string const& s) {
    int const n = s.size();
    std::vector<int> res(n);
    int i = 0, j = 0;
    while(i < n) {
        while(i - j >= 0 && i + j < n && s[i - j] == s[i + j]) ++j;
        res[i] = j;
        int k = 1;
        while(i - k >= 0 && i + k < n && k + res[i - k] < j) {
            res[i + k] = res[i - k];
            ++k;
        }
        i += k; j -= k;
    }
    return res;
}

class rolling_hash {
public:
    rolling_hash(std::string const& s)
        : n(s.size()), hs1(n + 1), hs2(n + 1), p1(n + 1, 1), p2(n + 1, 1)
    {
        for(int i = 0; i < n; ++i) {
            hs1[i + 1] = (hs1[i] * b1 + s[i]) % mod1;
            hs2[i + 1] = (hs2[i] * b2 + s[i]) % mod2;
            p1[i + 1] = p1[i] * b1 % mod1;
            p2[i + 1] = p2[i] * b2 % mod2;
        }
    }

    std::pair<ll, ll> query(int l, int r) const {
        return std::make_pair(((hs1[r] - hs1[l] * p1[r - l]) % mod1 + mod1) % mod1,
                              ((hs2[r] - hs2[l] * p2[r - l]) % mod2 + mod2) % mod2);
    }

private:
    const int n;
    std::vector<ll> hs1, hs2, p1, p2;
    static const ll b1 = 17LL;
    static const ll b2 = 19LL;
    static const ll mod1 = 999999937LL;
    static const ll mod2 = 1000000007LL;
};


map<pll, ll> calc(std::string s) {
    s = insert_doll(s);
    auto p = manacher(s);
    rolling_hash hs(s);
    map<pll, ll> cnt;
    int const n = s.size();
    vector<set<pll>> v(n);
    map<pll, pll> prev;
    for(int i = 0; i < n; ++i) {
        int l = i - p[i] + 2, r = i + p[i] - 1;
        if(l < r) {
            auto val = hs.query(l, r);
            v[r - l].insert(val);
            cnt[val]++;
            while(l + 2 < r - 2 && prev.count(val) == 0) {
                l += 2, r -= 2;
                auto val2 = hs.query(l, r);
                prev[val] = val2;
                val = val2;
                v[r - l].insert(val2);
            }
        }
    }
    for(int i = n - 1; i >= 2; --i) {
        for(auto& h : v[i]) {
            if(prev.count(h) == 1) {
                cnt[prev[h]] += cnt[h];
            }
        }
    }

    return cnt;
}

int main() {
    string s, t;
    cin >> s >> t;
    auto cnt1 = calc(s), cnt2 = calc(t);
    ll ans = 0;
    for(auto& p : cnt1) {
        if(cnt2.count(p.first) == 1) {
            ans += p.second * cnt2[p.first];
        }
    }
    cout << ans << endl;
}