#include <bits/stdc++.h>
using namespace std;
struct node {
  int nxt[30];
  int len;
  int link;
  bool leaf;
} t[300010];
int sz;
void sa(string s) {
  int last = 0;
  t[0].link = -1;
  sz = 1;
  for (int i = 0; i < s.size(); ++i) {
    int cur = sz++;
    t[cur].leaf = true;
    t[cur].len = t[last].len + 1;
    int p = last;
    for (; p != -1 && !t[p].nxt[s[i] - 'a']; p = t[p].link) {
      t[p].nxt[s[i] - 'a'] = cur;
    }
    if (p == -1) {
      t[cur].link = 0;
      last = cur;
      continue;
    }
    int q = t[p].nxt[s[i] - 'a'];
    if (t[q].len == t[p].len + 1) {
      t[cur].link = q;
      last = cur;
      continue;
    }
    int clone = sz++;
    t[clone].len = t[p].len + 1;
    memcpy(t[clone].nxt, t[q].nxt, sizeof t[q].nxt);
    for (; p != -1 && t[p].nxt[s[i] - 'a'] == q; p = t[p].link) {
      t[p].nxt[s[i] - 'a'] = clone;
    }
    t[clone].link = t[q].link;
    t[q].link = clone;
    t[cur].link = clone;
    last = cur;
  }
}
vector<int> rst[300010];
int cnt[300010];
void dfs(int x) {
  if (t[x].leaf) {
    cnt[x] = 1;
  }
  for (int i = 0; i < rst[x].size(); ++i) {
    dfs(rst[x][i]);
    cnt[x] += cnt[rst[x][i]];
  }
}
int res[100010];
int p[100010];
void prefix(string l) {
  int j = 0;
  for (int i = 1; i < l.size(); ++i) {
    while (j != 0 && l[i] != l[j]) {
      j = p[j - 1];
    }
    if (l[i] == l[j]) {
      ++j;
    }
    p[i] = j;
  }
}
int main() {
  string s, l;
  cin >> s >> l;
  s[0] = 'z' + 1;
  sa(s);
  for (int i = 1; i < sz; ++i) {
    rst[t[i].link].push_back(i);
  }
  dfs(0);
  int cur = 0;
  for (int i = 0; i < l.size(); ++i) {
    cur = t[cur].nxt[l[i] - 'a'];
    if (cur == 0) {
      break;
    }
    res[i] = cnt[cur];
  }
  prefix(l);
  long long ans = s.size() * 1ll * l.size();
  for (int i = 1; i < l.size(); ++i) {
    if (p[i]) {
      ans -= res[i - p[i]];
    }
  }
  printf("%lld\n", ans);
}
