#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define maxn 200007
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n, al;
P d[maxn], lcp[maxn];
char s[maxn];
void manacher() {
  int l = 1, r = 0;
  for (int i = 1; i <= n; i++) {
    d[i] = mp((i > r) ? 1 : min(r - i + 1, d[l + r - i].first), i);
    while (i - d[i].first >= 1 && i + d[i].first <= n 
           && s[i - d[i].first] == s[i + d[i].first]) 
      d[i].first++;
    if (i + d[i].first - 1 > r) {
      r = i + d[i].first - 1;
      l = i - d[i].first + 1;
    }
  }
}
namespace SA {
  int m, k, sa[maxn], rk[maxn << 1], cnt[maxn], id[maxn], tmp[maxn];
  void work() {
    m = 'Z';
    for (int i = 1; i <= n; i++) cnt[rk[i] = s[i]]++;
    for (int i = 1; i <= m; i++) cnt[i] += cnt[i - 1];
    for (int i = n; i >= 1; i--) sa[cnt[rk[i]]--] = i;
    m = 0;
    for (int i = 1; i <= n; i++) {
      if (rk[sa[i]] == rk[sa[i - 1]]) tmp[sa[i]] = m;
      else tmp[sa[i]] = ++m;
    }
    memcpy(rk, tmp, sizeof(tmp));
    for (int w = 1; m < n; w <<= 1) {
      k = 0;
      for (int i = n; i > n - w; i--) id[++k] = i;
      for (int i = 1; i <= n; i++) if (sa[i] > w) id[++k] = sa[i] - w;
      memset(cnt, 0, sizeof(cnt));
      for (int i = 1; i <= n; i++) cnt[lcp[i].first = rk[id[i]]]++;
      for (int i = 1; i <= m; i++) cnt[i] += cnt[i - 1];
      for (int i = n; i >= 1; i--) sa[cnt[lcp[i].first]--] = id[i];
      m = 0;
      for (int i = 1; i <= n; i++) {
        if (rk[sa[i]] == rk[sa[i - 1]] && rk[sa[i] + w] == rk[sa[i - 1] + w]) {
          tmp[sa[i]] = m;
        } else {
          tmp[sa[i]] = ++m;
        }
      }
      memcpy(rk, tmp, sizeof(tmp));
    }
    k = 0;
    for (int i = 1; i <= n; i++) {
      if (k) k--;
      while (s[i + k] == s[sa[rk[i] - 1] + k]) k++;
      lcp[rk[i]] = mp(k, rk[i]);
    }
  }
}
ll cur, ans;
namespace uf {
  int par[maxn], numa[maxn], numb[maxn];
  void init(int n) {
    for (int i = 1; i <= n; i++) par[i] = i;
  }
  int fin(int u) {
    if (par[u] == u) return u;
    return par[u] = fin(par[u]);
  }
  void uni(int u, int v) {
    u = fin(u), v = fin(v);
    if (u == v) return;
    par[u] = v;
    cur -= (ll)numa[u] * numb[u];
    cur -= (ll)numa[v] * numb[v];
    numa[v] += numa[u], numb[v] += numb[u];
    cur += (ll)numa[v] * numb[v];
  }
  void adda(int u) {
    u = fin(u);
    numa[u]++;
    cur += numb[u];
  }
  void addb(int u) {
    u = fin(u);
    numb[u]++;
    cur += numa[u];
  }
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  s[++n] = '$';
  al = n << 1;
  scanf("%s", s + n + 1);
  n = strlen(s + 1) * 2 + 1;
  for (int i = n; i >= 1; i--) {
    if (i & 1) s[i] = '#';
    else s[i] = s[i >> 1];
  }
  manacher();
  SA::work();
  sort(d + 1, d + n + 1, greater<P>());
  sort(lcp + 1, lcp + n + 1, greater<P>());
  int dk = 1, lcpk = 1;
  uf::init(n);
  for (int i = n; i >= 1; i--) {
    while (dk <= n && d[dk].first == i) {
      int pos = d[dk].second;
      if (pos <= al) uf::adda(SA::rk[pos]);
      else uf::addb(SA::rk[pos]);
      dk++;
    }
    while (lcpk <= n && lcp[lcpk].first == i) {
      uf::uni(lcp[lcpk].second, lcp[lcpk].second - 1);
      lcpk++;
    }
    ans += cur;
  }
  (ans -= (ll)al * (n - al + 1) / 4) /= 2;
  printf("%lld\n", ans); 
  return 0;
}


Measured memory_bytes: 13204