#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
void qread(int &x) {
  int neg = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = 10 * x + c - '0', c = getchar();
  x *= neg;
}
const int maxn = 200005;
const int maxm = 26;
int n, m;
char c[maxn];
string s, t;
int z[maxn];
long long ans;
void zalgo(string s) {
  int l = 0, r = 0;
  for (int(i) = 1; (i) <= s.size() - 1; i++) {
    if (i < r) z[i] = min(z[i - l], r - i);
    while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) z[i]++;
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
}
namespace Sam {
int tot, last, rt;
int nxt[maxn * 2][maxm], par[maxn * 2], val[maxn * 2];
int res[maxn * 2], pos[maxn * 2];
vector<pair<int, int> > ord;
int newnode(int _val) {
  tot++;
  for (int(i) = 0; (i) < 26; i++) nxt[tot][i] = 0;
  par[tot] = 0;
  val[tot] = _val;
  return tot;
}
void init() {
  tot = 0;
  rt = newnode(0);
  last = rt;
}
void add(int c, int i) {
  int p = last, np = newnode(val[p] + 1);
  pos[i] = np;
  while (p && !nxt[p][c]) nxt[p][c] = np, p = par[p];
  if (!p)
    par[np] = rt;
  else {
    int q = nxt[p][c];
    if (val[q] == val[p] + 1)
      par[np] = q;
    else {
      int nq = newnode(val[p] + 1);
      for (int(i) = 0; (i) < 26; i++) nxt[nq][i] = nxt[q][i];
      par[nq] = par[q];
      par[np] = par[q] = nq;
      while (p && nxt[p][c] == q) nxt[p][c] = nq, p = par[p];
    }
  }
  last = np;
}
void work() {
  for (int(i) = 1; (i) <= tot; i++) ord.push_back(make_pair(val[i], i));
  sort(ord.begin(), ord.end());
  for (int(i) = 0; (i) < tot; i++) {
    int x = ord[i].second;
    if (par[x]) res[x] = max(res[x], res[par[x]]);
  }
  for (int(i) = 1; (i) <= n - 1; i++) ans += m - res[pos[i]];
}
}  // namespace Sam
int main() {
  scanf("%s", c);
  s = c;
  n = s.size();
  scanf("%s", c);
  t = c;
  m = t.size();
  zalgo(t);
  Sam::init();
  for (int(i) = 1; (i) <= n - 1; i++) Sam::add(s[i] - 'a', i);
  int cur = Sam::rt;
  z[0] = m;
  for (int(i) = 0; (i) < m - 1; i++) {
    if (!Sam::nxt[cur][t[i] - 'a']) break;
    cur = Sam::nxt[cur][t[i] - 'a'];
    Sam::res[cur] = max(Sam::res[cur], min(z[i + 1], m - 1 - i));
  }
  Sam::work();
  printf("%lld\n", ans + m);
  return 0;
}
