#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 30;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
struct T {
  long long v;
  T(long long v = inf) : v(v) {}
  T operator+(const T& t) { return T(min(v, t.v)); }
  friend ostream& operator<<(ostream& out, const T& t) {
    out << t.v;
    return out;
  }
};
struct segtree {
  int n;
  vector<T> seg;
  void init(int mx) {
    n = 1;
    while (n < mx) n *= 2;
    seg = vector<T>(n * 2);
  }
  segtree(int mx = 0) { init(mx); }
  void update(int i, T x) {
    i += n - 1;
    seg[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      seg[i] = seg[i * 2 + 1] + seg[i * 2 + 2];
    }
  }
  T ga(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return T();
    if (a <= l && r <= b)
      return seg[k];
    else {
      T lv = ga(a, b, k * 2 + 1, l, (l + r) / 2);
      T rv = ga(a, b, k * 2 + 2, (l + r) / 2, r);
      return lv + rv;
    }
  }
  void show() {
    vector<T> tmp;
    for (int i = int(0); i < int(n); i++) tmp.push_back(get(i, i + 1));
    Debug(91, ":", tmp);
  }
  T get(int a, int b) { return ga(a, b, 0, 0, n); }
};
struct SA {
  int n;
  vector<int> S, sa, rank, bkt;
  vector<int> lcp;
  segtree seg;
  void init(const vector<int>& sin, int K = 27) {
    n = (int)sin.size();
    S.resize(n + 1);
    rank.resize(n + 1);
    for (int i = int(0); i < int(n); i++) S[i] = sin[i] + 1;
    bkt.resize(max(n + 1, K + 1));
    sa = get_sa(S, K + 1);
    for (int i = int(0); i < int(n + 1); i++) rank[sa[i]] = i;
    get_lcp();
    seg.init(n);
    for (int i = int(0); i < int(n); i++) seg.update(i, lcp[i]);
  }
  inline bool isLMS(const vector<int>& t, int i) {
    if (i > 0 && t[i] && !t[i - 1])
      return true;
    else
      return false;
  }
  void getBuckets(const vector<int>& s, int K, bool end) {
    int sum = 0, n = (int)s.size();
    fill(bkt.begin(), bkt.begin() + K, 0);
    for (int i = int(0); i < int(n); i++) bkt[s[i]]++;
    for (int i = int(0); i < int(K); i++) {
      sum += bkt[i];
      bkt[i] = end ? sum : sum - bkt[i];
    }
  }
  void induceSAl(const vector<int>& t, const vector<int>& s, vector<int>& SA,
                 int K) {
    int n = (int)SA.size();
    getBuckets(s, K, false);
    for (int i = int(0); i < int(n); i++) {
      int j = SA[i] - 1;
      if (j >= 0 && !t[j]) SA[bkt[s[j]]++] = j;
    }
  }
  void induceSAs(const vector<int>& t, const vector<int>& s, vector<int>& SA,
                 int K) {
    int n = (int)SA.size();
    getBuckets(s, K, true);
    for (int i = int(n) - 1; i >= int(0); i--) {
      int j = SA[i] - 1;
      if (j >= 0 && t[j]) SA[--bkt[s[j]]] = j;
    }
  }
  vector<int> get_sa(const vector<int>& s, int K) {
    int n = (int)s.size();
    vector<int> t(n, 0);
    t[n - 1] = 1;
    t[n - 2] = 0;
    for (int i = int(n - 2) - 1; i >= int(0); i--)
      if (s[i] < s[i + 1] || (s[i] == s[i + 1] && t[i + 1] == 1)) t[i] = 1;
    getBuckets(s, K, true);
    vector<int> SA(n, -1);
    for (int i = int(1); i < int(n); i++)
      if (isLMS(t, i)) SA[--bkt[s[i]]] = i;
    induceSAl(t, s, SA, K);
    induceSAs(t, s, SA, K);
    int n1 = 0;
    for (int i = int(0); i < int(n); i++)
      if (isLMS(t, SA[i])) SA[n1++] = SA[i];
    fill(SA.begin() + n1, SA.end(), -1);
    int name = 0, prev = -1;
    for (int i = int(0); i < int(n1); i++) {
      int pos = SA[i];
      bool diff = false;
      for (int d = int(0); d < int(n); d++) {
        if (prev == -1 || s[pos + d] != s[prev + d] ||
            t[pos + d] != t[prev + d]) {
          diff = true;
          break;
        } else if (d > 0 && (isLMS(t, pos + d) || isLMS(t, prev + d)))
          break;
      }
      if (diff) {
        name++;
        prev = pos;
      }
      pos = (pos % 2 == 0) ? pos / 2 : (pos - 1) / 2;
      SA[n1 + pos] = name - 1;
    }
    vector<int> s1(n1, -1), SA1(n1, -1), p1(n1, -1);
    int at = 0;
    for (int i = int(n1); i < int(n); i++)
      if (SA[i] >= 0) s1[at++] = SA[i];
    if (name < n1)
      SA1 = get_sa(s1, name);
    else
      for (int i = int(0); i < int(n1); i++) SA1[s1[i]] = i;
    getBuckets(s, K, true);
    at = 0;
    for (int i = int(1); i < int(n); i++)
      if (isLMS(t, i)) p1[at++] = i;
    fill((SA).begin(), (SA).end(), -1);
    for (int i = int(n1) - 1; i >= int(0); i--) {
      int j = p1[SA1[i]];
      SA[--bkt[s[j]]] = j;
    }
    induceSAl(t, s, SA, K);
    induceSAs(t, s, SA, K);
    return SA;
  }
  void get_lcp() {
    lcp.resize(n);
    int h = 0;
    lcp[0] = 0;
    for (int i = int(0); i < int(n); i++) {
      int j = sa[rank[i] - 1];
      if (h > 0) h--;
      while (j + h < n && i + h < n && S[j + h] == S[i + h]) h++;
      lcp[rank[i] - 1] = h;
    }
  }
  int common(int i, int j) {
    if (i == j)
      return n - i;
    else {
      int a = rank[i], b = rank[j];
      if (a > b) swap(a, b);
      return seg.get(a, b).v;
    }
  }
};
vector<int> MP(string S) {
  int n = (int)S.size();
  vector<int> A(n + 1);
  A[0] = -1;
  for (int i = int(0); i < int(n); i++) {
    int j = A[i];
    while (j >= 0 && S[i] != S[j]) j = A[j];
    j++;
    A[i + 1] = j;
  }
  return A;
}
int N, M;
string S, T;
int fd(const vector<int>& vec, int a) {
  return upper_bound((vec).begin(), (vec).end(), a) - vec.begin();
}
void solve() {
  cin >> S >> T;
  vector<int> vt = MP(T);
  int N = (int)(S).size(), M = (int)(T).size();
  SA sa;
  vector<int> vs;
  for (int i = int(0); i < int(N); i++) vs.push_back(S[i] - 'a');
  vs.push_back(26);
  for (int i = int(0); i < int(M); i++) vs.push_back(T[i] - 'a');
  sa.init(vs, 27);
  vector<int> vec;
  for (int i = int(1); i < int(M + 1); i++) {
    if (vt[i]) {
      vec.push_back(i - vt[i]);
    }
  }
  long long res = 1ll * N * M;
  for (int i = int(1); i < int(N); i++) {
    int d = sa.common(i, N + 1);
    res -= fd(vec, d);
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  srand((unsigned int)time(NULL));
  solve();
  return 0;
}
