#include <bits/stdc++.h>
using namespace std;
vector<int> zfunc(string s) {
  vector<int> z(s.size() + 1);
  z[0] = s.size();
  for (int i = 1, l = 0, r = 0; i < s.size(); ++i) {
    z[i] = (i > r ? 0 : min(z[i - l], r - i + 1));
    while (i + z[i] < s.size() && s[i + z[i]] == s[z[i]]) ++z[i];
    if (i + z[i] > r) {
      l = i, r = i + z[i] - 1;
    }
  }
  return z;
}
vector<int> BuildKMP(string t) {
  vector<int> kmp(t.size());
  for (int i = 1, k = 0; i < t.size(); ++i) {
    while (k && t[k] != t[i]) k = kmp[k - 1];
    if (t[k] == t[i]) ++k;
    kmp[i] = k;
  }
  return kmp;
}
vector<int> KMP(string s, string t, vector<int> kmp) {
  vector<int> f(s.size() + 1);
  for (int i = 0, k = 0; i < s.size(); ++i) {
    while (k && t[k] != s[i]) k = kmp[k - 1];
    if (t[k] == s[i]) ++k;
    f[i] = k;
    if (k == i + 1) f[i] = kmp[k - 1];
    if (k == t.size()) k = kmp[k - 1];
  }
  return f;
}
int main() {
  string s, t;
  cin >> s >> t;
  vector<int> z = zfunc(t);
  vector<int> kmp = BuildKMP(t);
  vector<int> f = KMP(s, t, kmp);
  long long ans = 1ll * s.size() * t.size();
  for (int i = 1; i <= t.size(); ++i)
    if (kmp[i - 1]) {
      z[i] = max(z[i], z[kmp[i - 1]]);
    }
  for (int i = 1; i < s.size(); ++i) {
    if (f[i]) ans -= z[f[i]];
  }
  cout << ans;
}
