#include <bits/stdc++.h>
using namespace std;
namespace SA {
char s[100005];
int n, lcp[200005], cnt[200005], vy[200005], rk[200005], tmp[200005],
    ls[200005];
void bsort() {
  int i;
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < n; ++i) ++cnt[vy[i]];
  for (i = 1; i <= n + 3 || i <= 30; ++i) cnt[i] += cnt[i - 1];
  for (i = n - 1; i >= 0; --i) tmp[--cnt[vy[i]]] = i;
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < n; ++i) ++cnt[rk[tmp[i]]];
  for (i = 1; i <= n + 3 || i <= 30; ++i) cnt[i] += cnt[i - 1];
  for (i = n - 1; i >= 0; --i) ls[--cnt[rk[tmp[i]]]] = tmp[i];
  memset(tmp, 0, sizeof(tmp));
}
void getsa() {
  int i, j, cv;
  memset(rk, 0, sizeof(rk));
  memset(vy, 0, sizeof(vy));
  for (i = 0; i < n; ++i) {
    rk[i] = s[i] - 'a' + 1;
  }
  for (i = 2; i <= n * 2; i <<= 1) {
    for (j = 0; j < n; ++j) {
      vy[j] = rk[j + (i >> 1)];
    }
    bsort();
    cv = 1;
    for (j = 0; j < n; ++j) {
      if (j && (rk[ls[j - 1]] != rk[ls[j]] || vy[ls[j - 1]] != vy[ls[j]])) ++cv;
      tmp[ls[j]] = cv;
    }
    memcpy(rk, tmp, sizeof(tmp));
  }
}
void getlcp() {
  int i, j, lv = 0;
  for (i = 0; i < n; ++i) {
    if (rk[i] == 1) continue;
    int la = ls[rk[i] - 2];
    for (j = max(0, lv - 2); la + j < n && i + j < n; ++j) {
      if (s[la + j] != s[i + j]) break;
    }
    lcp[i] = lv = j;
  }
}
};  // namespace SA
char s[100005], t[100005];
int ls, lt, app[100005], nx[100005];
int main() {
  int i, j, k;
  scanf("%s", s);
  scanf("%s", t);
  ls = strlen(s);
  lt = strlen(t);
  SA::n = ls;
  memcpy(SA::s, s, sizeof(s));
  SA::getsa();
  SA::getlcp();
  int lb = 0, rb = ls - 1, zp = -1;
  for (i = 0; i < ls; ++i) {
    if (SA::ls[i] == 0) zp = i;
  }
  for (i = 0; i < lt; ++i) {
    while (lb <= rb) {
      if (ls - SA::ls[lb] >= i + 1 && s[SA::ls[lb] + i] == t[i]) break;
      ++lb;
    }
    while (lb <= rb) {
      if (ls - SA::ls[rb] >= i + 1 && s[SA::ls[rb] + i] == t[i]) break;
      --rb;
    }
    if (lb > rb) break;
    app[i] = rb - lb + 1;
    if (rb >= zp && lb <= zp) --app[i];
  }
  j = 0;
  for (i = 1; i < lt; ++i) {
    while (j && t[j] != t[i]) j = nx[j - 1];
    if (t[j] == t[i]) nx[i] = ++j;
  }
  long long res = (long long)ls * (long long)lt;
  for (i = 0; i < lt; ++i) {
    if (nx[i]) {
      res -= (long long)app[i - nx[i]];
    }
  }
  printf("%I64d\n", res);
  return 0;
}
