#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; vector< int > manacher(const string &s) { int n=s.size(); vector< int > radius(n); int i = 0, j = 0; while(i < n) { while(i - j >= 0 && i + j < n && s[i - j] == s[i + j]) { ++j; } radius[i] = j; int k = 1; while(i - k >= 0 && i + k < n && k + radius[i - k] < j) { radius[i + k] = radius[i - k]; ++k; } i += k; j -= k; } return radius; } template struct RollingHash{ vector hash, power; RollingHash(const string &s, ll base=10007){ int sz=s.size(); hash.resize(sz+1); power.resize(sz+1); power[0]=1; for(int i=0; i=mod) ret-=mod; return ret; } ll concat(ll h1, ll h2, int len2) const{ //h1+h2 ll ret=h1*power[len2]%mod+h2; if(ret>=mod) ret-=mod; return ret; } }; int main() { string s[2]; cin>>s[0]>>s[1]; unordered_map mps[2]; for(int z=0; z<2; z++){ int n=s[z].size(); string s1="#"; for(int i=0; i rs1(s[z]); RollingHash rs2(s[z]); vector>> ss(n+1); for(int i=0; i>1); if(u==0) continue; l=i-u+1, r=i+1+u; x=(rs1.get(l, r)<<30)^rs2.get(l, r); if(mps[z].find(x)==mps[z].end()) ss[r-l].push_back({l, x}); mps[z][x]++; } for(int d=n; d>=3; d--){ for(auto p:ss[d]){ int l=p.first; ll x0=p.second; ll x=(rs1.get(l+1, l+d-1)<<30)^rs2.get(l+1, l+d-1); if(mps[z].find(x)==mps[z].end()) ss[d-2].push_back({l+1, x}); mps[z][x]+=mps[z][x0]; } } } ll ans=0; for(auto p:mps[0]){ ll x=p.first; if(mps[1].find(x)!=mps[1].end()){ ans+=mps[1][x]*p.second; } } cout<