#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c h, n;
};
template <class c>
rge<c> range(c h, c n) {
  return rge<c>{h, n};
}
template <class c, class F>
struct rgm {
  c h, n;
  F f;
};
template <class c, class F>
rgm<c, F> map_range(c b, c e, F f) {
  return rgm<c, F>{b, e, f};
}
template <class c, class F>
rgm<typename c::const_iterator, F> map_range(const c &x, F f) {
  return map_range(x.begin(), x.end(), f);
}
template <class c, class F>
struct umm {
  c m;
  F f;
  bool r;
};
template <class c, class F>
umm<c, F> mask_iter(c a, F f, bool r = false) {
  return umm<c, F>{a, f, r};
}
template <class c>
auto dud(c *r) -> decltype(cerr << *r);
template <class c>
char dud(...);
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using unt = unsigned int;
int popc(unt a) { return __builtin_popcount(a); }
int popc(int a) { return __builtin_popcount(a); }
int popc(ll a) { return __builtin_popcountll(a); }
int popc(ull a) { return __builtin_popcountll(a); }
int ctz(unt a) { return __builtin_ctz(a); }
int ctz(int a) { return __builtin_ctz(a); }
int ctz(ll a) { return __builtin_ctzll(a); }
int ctz(ull a) { return __builtin_ctzll(a); }
int clz(unt a) { return __builtin_clz(a); }
int clz(int a) { return __builtin_clz(a); }
int clz(ll a) { return __builtin_clzll(a); }
int clz(ull a) { return __builtin_clzll(a); }
struct muu {
  template <class c>
  muu &operator<<(const c &) {
    return *this;
  }
};
template <class c>
void factor(muu &d, c x) {
  if (x <= 1 && x + 1 >= 0) {
    d << x;
    return;
  }
  d << x << "=";
  if (x < 0) {
    d << "-";
    x = -x;
  }
  int q = 0;
  for (c p = 2; p * p < x; ++p) {
    int e = 0;
    while (x % p == 0) {
      e++;
      x /= p;
    }
    if (e) d << "*" + !q++ << p;
    if (e > 1) d << "^" << e;
  }
  if (x > 1) d << "*" + !q++ << x;
}
template <class c>
void mini(c &a, c b) {
  if (a > b) a = b;
}
template <class c>
void maxi(c &a, c b) {
  if (a < b) a = b;
}
template <class c, class d, class e, class f>
auto operator+(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first + b.first, a.second + b.second)) {
  return {a.first + b.first, a.second + b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator+(c a, pair<d, e> b)
    -> decltype(make_pair(a + b.first, a + b.second)) {
  return {a + b.first, a + b.second};
}
template <class c, class d, class e>
auto operator+(pair<c, d> a, e b)
    -> decltype(make_pair(a.first + b, a.second + b)) {
  return {a.first + b, a.second + b};
}
template <class c, class d, class e>
void operator+=(pair<c, d> &a, e b) {
  a.first += b;
  a.second += b;
}
template <class c, class d, class e, class f>
void operator+=(pair<c, d> &a, pair<e, f> b) {
  a.first += b.first;
  a.second += b.second;
}
template <class c, class d, class e, class f>
auto operator-(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first - b.first, a.second - b.second)) {
  return {a.first - b.first, a.second - b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator-(c a, pair<d, e> b)
    -> decltype(make_pair(a - b.first, a - b.second)) {
  return {a - b.first, a - b.second};
}
template <class c, class d, class e>
auto operator-(pair<c, d> a, e b)
    -> decltype(make_pair(a.first - b, a.second - b)) {
  return {a.first - b, a.second - b};
}
template <class c, class d, class e>
void operator-=(pair<c, d> &a, e b) {
  a.first -= b;
  a.second -= b;
}
template <class c, class d, class e, class f>
void operator-=(pair<c, d> &a, pair<e, f> b) {
  a.first -= b.first;
  a.second -= b.second;
}
template <class c, class d, class e, class f>
auto operator*(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first * b.first, a.second *b.second)) {
  return {a.first * b.first, a.second * b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator*(c a, pair<d, e> b)
    -> decltype(make_pair(a * b.first, a *b.second)) {
  return {a * b.first, a * b.second};
}
template <class c, class d, class e>
auto operator*(pair<c, d> a, e b)
    -> decltype(make_pair(a.first * b, a.second *b)) {
  return {a.first * b, a.second * b};
}
template <class c, class d, class e>
void operator*=(pair<c, d> &a, e b) {
  a.first *= b;
  a.second *= b;
}
template <class c, class d, class e, class f>
void operator*=(pair<c, d> &a, pair<e, f> b) {
  a.first *= b.first;
  a.second *= b.second;
}
template <class c, class d, class e, class f>
auto operator/(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first / b.first, a.second / b.second)) {
  return {a.first / b.first, a.second / b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator/(c a, pair<d, e> b)
    -> decltype(make_pair(a / b.first, a / b.second)) {
  return {a / b.first, a / b.second};
}
template <class c, class d, class e>
auto operator/(pair<c, d> a, e b)
    -> decltype(make_pair(a.first / b, a.second / b)) {
  return {a.first / b, a.second / b};
}
template <class c, class d, class e>
void operator/=(pair<c, d> &a, e b) {
  a.first /= b;
  a.second /= b;
}
template <class c, class d, class e, class f>
void operator/=(pair<c, d> &a, pair<e, f> b) {
  a.first /= b.first;
  a.second /= b.second;
}
template <class c, class d, class e, class f>
auto operator%(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first % b.first, a.second % b.second)) {
  return {a.first % b.first, a.second % b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator%(c a, pair<d, e> b)
    -> decltype(make_pair(a % b.first, a % b.second)) {
  return {a % b.first, a % b.second};
}
template <class c, class d, class e>
auto operator%(pair<c, d> a, e b)
    -> decltype(make_pair(a.first % b, a.second % b)) {
  return {a.first % b, a.second % b};
}
template <class c, class d, class e>
void operator%=(pair<c, d> &a, e b) {
  a.first %= b;
  a.second %= b;
}
template <class c, class d, class e, class f>
void operator%=(pair<c, d> &a, pair<e, f> b) {
  a.first %= b.first;
  a.second %= b.second;
}
template <class c, class d, class e, class f>
auto operator^(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first ^ b.first, a.second ^ b.second)) {
  return {a.first ^ b.first, a.second ^ b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator^(c a, pair<d, e> b)
    -> decltype(make_pair(a ^ b.first, a ^ b.second)) {
  return {a ^ b.first, a ^ b.second};
}
template <class c, class d, class e>
auto operator^(pair<c, d> a, e b)
    -> decltype(make_pair(a.first ^ b, a.second ^ b)) {
  return {a.first ^ b, a.second ^ b};
}
template <class c, class d, class e>
void operator^=(pair<c, d> &a, e b) {
  a.first ^= b;
  a.second ^= b;
}
template <class c, class d, class e, class f>
void operator^=(pair<c, d> &a, pair<e, f> b) {
  a.first ^= b.first;
  a.second ^= b.second;
}
template <class c, class d, class e, class f>
auto operator|(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first | b.first, a.second | b.second)) {
  return {a.first | b.first, a.second | b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator|(c a, pair<d, e> b)
    -> decltype(make_pair(a | b.first, a | b.second)) {
  return {a | b.first, a | b.second};
}
template <class c, class d, class e>
auto operator|(pair<c, d> a, e b)
    -> decltype(make_pair(a.first | b, a.second | b)) {
  return {a.first | b, a.second | b};
}
template <class c, class d, class e>
void operator|=(pair<c, d> &a, e b) {
  a.first |= b;
  a.second |= b;
}
template <class c, class d, class e, class f>
void operator|=(pair<c, d> &a, pair<e, f> b) {
  a.first |= b.first;
  a.second |= b.second;
}
template <class c, class d, class e, class f>
auto operator>>(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first >> b.first, a.second >> b.second)) {
  return {a.first >> b.first, a.second >> b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator>>(c a, pair<d, e> b)
    -> decltype(make_pair(a >> b.first, a >> b.second)) {
  return {a >> b.first, a >> b.second};
}
template <class c, class d, class e>
auto operator>>(pair<c, d> a, e b)
    -> decltype(make_pair(a.first >> b, a.second >> b)) {
  return {a.first >> b, a.second >> b};
}
template <class c, class d, class e>
void operator>>=(pair<c, d> &a, e b) {
  a.first >>= b;
  a.second >>= b;
}
template <class c, class d, class e, class f>
void operator>>=(pair<c, d> &a, pair<e, f> b) {
  a.first >>= b.first;
  a.second >>= b.second;
}
template <class c, class d, class e, class f>
auto operator<<(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first << b.first, a.second << b.second)) {
  return {a.first << b.first, a.second << b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator<<(c a, pair<d, e> b)
    -> decltype(make_pair(a << b.first, a << b.second)) {
  return {a << b.first, a << b.second};
}
template <class c, class d, class e>
auto operator<<(pair<c, d> a, e b)
    -> decltype(make_pair(a.first << b, a.second << b)) {
  return {a.first << b, a.second << b};
}
template <class c, class d, class e>
void operator<<=(pair<c, d> &a, e b) {
  a.first <<= b;
  a.second <<= b;
}
template <class c, class d, class e, class f>
void operator<<=(pair<c, d> &a, pair<e, f> b) {
  a.first <<= b.first;
  a.second <<= b.second;
}
template <class c, class d, class e, class f>
auto operator&(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first & b.first, a.second &b.second)) {
  return {a.first & b.first, a.second & b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator&(c a, pair<d, e> b)
    -> decltype(make_pair(a & b.first, a &b.second)) {
  return {a & b.first, a & b.second};
}
template <class c, class d, class e>
auto operator&(pair<c, d> a, e b)
    -> decltype(make_pair(a.first & b, a.second &b)) {
  return {a.first & b, a.second & b};
}
template <class c, class d, class e>
void operator&=(pair<c, d> &a, e b) {
  a.first &= b;
  a.second &= b;
}
template <class c, class d, class e, class f>
void operator&=(pair<c, d> &a, pair<e, f> b) {
  a.first &= b.first;
  a.second &= b.second;
}
template <class c, class d, class e, class f>
auto operator&&(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first && b.first, a.second &&b.second)) {
  return {a.first && b.first, a.second && b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator&&(c a, pair<d, e> b)
    -> decltype(make_pair(a && b.first, a &&b.second)) {
  return {a && b.first, a && b.second};
}
template <class c, class d, class e>
auto operator&&(pair<c, d> a, e b)
    -> decltype(make_pair(a.first && b, a.second &&b)) {
  return {a.first && b, a.second && b};
}
template <class c, class d, class e, class f>
auto operator||(pair<c, d> a, pair<e, f> b)
    -> decltype(make_pair(a.first || b.first, a.second || b.second)) {
  return {a.first || b.first, a.second || b.second};
}
template <class c, class d, class e,
          class = typename enable_if<!is_same<c, muu>::value>::type>
auto operator||(c a, pair<d, e> b)
    -> decltype(make_pair(a || b.first, a || b.second)) {
  return {a || b.first, a || b.second};
}
template <class c, class d, class e>
auto operator||(pair<c, d> a, e b)
    -> decltype(make_pair(a.first || b, a.second || b)) {
  return {a.first || b, a.second || b};
}
template <class c, class d>
auto operator-(pair<c, d> e) -> decltype(make_pair(-e.first, -e.second)) {
  return {-e.first, -e.second};
}
template <class c, class d>
auto operator+(pair<c, d> e) -> decltype(make_pair(+e.first, +e.second)) {
  return {+e.first, +e.second};
}
template <class c, class d>
auto operator~(pair<c, d> e) -> decltype(make_pair(~e.first, ~e.second)) {
  return {~e.first, ~e.second};
}
template <class c, class d>
auto operator!(pair<c, d> e) -> decltype(make_pair(!e.first, !e.second)) {
  return {!e.first, !e.second};
}
ull mix(ull x) {
  x += 0x9e3779b97f4a7c15;
  x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
  x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
  return x ^ (x >> 31);
}
struct suffix_automaton;
struct suffix_automaton {
  vector<map<char, int>> edges;
  vector<int> link;
  vector<int> length;
  int last;
  suffix_automaton(string s) {
    edges.push_back(map<char, int>());
    link.push_back(-1);
    length.push_back(0);
    last = 0;
    for (int i = 0; i < (int)s.size(); i++) {
      edges.push_back(map<char, int>());
      length.push_back(i + 1);
      link.push_back(0);
      int r = edges.size() - 1;
      int p = last;
      while (p >= 0 && !edges[p].count(s[i])) {
        edges[p][s[i]] = r;
        p = link[p];
      }
      if (p != -1) {
        int q = edges[p][s[i]];
        if (length[p] + 1 == length[q]) {
          link[r] = q;
        } else {
          edges.push_back(edges[q]);
          length.push_back(length[p] + 1);
          link.push_back(link[q]);
          int qq = edges.size() - 1;
          link[q] = link[r] = qq;
          while (p >= 0 && edges[p][s[i]] == q) {
            edges[p][s[i]] = qq;
            p = link[p];
          }
        }
      }
      last = r;
    }
  }
  suffix_automaton() {}
};
const int nax = 2e5 + 44;
char a[nax], b[nax];
bool seen[nax];
int kmp[nax];
int cou[nax];
int occs[nax];
suffix_automaton aut;
void dfs(int x) {
  if (seen[x]) return;
  seen[x] = 1;
  for (auto p : aut.edges[x]) {
    dfs(p.second);
    cou[x] += cou[p.second];
  }
}
int main() {
  scanf("%s%s", a, b);
  int n = strlen(a), m = strlen(b);
  aut = suffix_automaton(a + 1);
  (muu() << "\033[1;" << 30 + 263 % 8 << "m" << __FUNCTION__ << "#" << 263
         << ": \033[" << 30 + (int)(263 * 3.125) % 8 << "m")
      << "["
         "aut"
         ": "
      << (aut) << "] ";
  int y = aut.last;
  while (y != -1) {
    int prev = aut.link[y];
    cou[y] = 1;
    y = prev;
  }
  dfs(0);
  (muu() << "\033[1;" << 30 + 271 % 8 << "m" << __FUNCTION__ << "#" << 271
         << ": \033[" << 30 + (int)(271 * 3.125) % 8 << "m")
      << range(cou, cou + aut.edges.size());
  int wh = 0;
  occs[0] = cou[0];
  for (typename remove_cv<typename remove_reference<decltype(m)>::type>::type
           i = 0;
       i < m; ++i) {
    if (aut.edges[wh].count(b[i])) {
      wh = aut.edges[wh][b[i]];
      occs[i + 1] = cou[wh];
    } else
      break;
  }
  (muu() << "\033[1;" << 30 + 281 % 8 << "m" << __FUNCTION__ << "#" << 281
         << ": \033[" << 30 + (int)(281 * 3.125) % 8 << "m")
      << range(occs, occs + m + 1);
  for (auto i = 1; i <= m - 1; ++i) {
    int x = kmp[i];
    while (x && b[x] != b[i]) x = kmp[x];
    kmp[i + 1] = x;
    if (b[i] == b[kmp[i + 1]]) kmp[i + 1]++;
    (muu() << "\033[1;" << 30 + 287 % 8 << "m" << __FUNCTION__ << "#" << 287
           << ": \033[" << 30 + (int)(287 * 3.125) % 8 << "m")
        << "["
           "kmp"
           "["
           "i + 1"
           ": "
        << (i + 1)
        << "] "
           ": "
        << kmp[i + 1] << "] ";
  }
  (muu() << "\033[1;" << 30 + 289 % 8 << "m" << __FUNCTION__ << "#" << 289
         << ": \033[" << 30 + (int)(289 * 3.125) % 8 << "m")
      << range(kmp, kmp + m + 1);
  ll ans = n;
  for (auto i = 2; i <= m; ++i) {
    if (kmp[i]) {
      (muu() << "\033[1;" << 30 + 293 % 8 << "m" << __FUNCTION__ << "#" << 293
             << ": \033[" << 30 + (int)(293 * 3.125) % 8 << "m")
          << "["
             "kmp"
             "["
             "i"
             ": "
          << (i)
          << "] "
             ": "
          << kmp[i]
          << "] "
             "["
             "occs"
             "["
             "i - kmp[i]"
             ": "
          << (i - kmp[i])
          << "] "
             ": "
          << occs[i - kmp[i]] << "] ";
      ans += n - occs[i - kmp[i]];
    } else
      ans += n;
  }
  printf("%lld\n", ans);
}
