#include <bits/stdc++.h>
using namespace std;
using LL = long long;
template <class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
using LD = long double;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') {
    cerr << *sdbg++;
  }
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
vector<int> prefix_function(string s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; i++) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  return pi;
}
vector<int> z_function(string s) {
  int n = (int)s.length();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
long long solve(string &s, string &t) {
  auto failCombined = prefix_function(t + '$' + s);
  auto failT = prefix_function(t);
  auto zT = z_function(t);
  int n = (int)t.size();
  vector<int> dp(n, 0);
  dp[0] = (n == 1 ? 0 : zT[1]);
  for (int i = 1; i < n; i++) {
    if (i != n - 1) dp[i] = zT[i + 1];
    if (failT[i]) dp[i] = max(dp[i], dp[failT[i] - 1]);
  }
  LL ans = n;
  for (int i = 1; i < (int)s.size(); i++) {
    int matching = failCombined[n + 1 + i];
    if (!matching) {
      ans += n;
      continue;
    }
    int nxt = 0;
    if (i + 1 != matching)
      nxt = dp[matching - 1];
    else {
      nxt = (failT[matching - 1] ? dp[failT[matching - 1] - 1] : 0);
    }
    ans += (n - nxt);
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (0) cout.tie(NULL);
  string s, t;
  cin >> s >> t;
  cout << solve(s, t) << '\n';
  if (0)
    cout << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
         << '\n';
  return 0;
}
