Misha didn't do his math homework for today's lesson once again. As a punishment, his teacher Dr. Andrew decided to give him a hard, but very useless task.

Dr. Andrew has written two strings s and t of lowercase English letters at the blackboard. He reminded Misha that prefix of a string is a string formed by removing several (possibly none) of its last characters, and a concatenation of two strings is a string formed by appending the second string to the right of the first string.

The teacher asked Misha to write down on the blackboard all strings that are the concatenations of some non-empty prefix of s and some non-empty prefix of t. When Misha did it, Dr. Andrew asked him how many distinct strings are there. Misha spent almost the entire lesson doing that and completed the task. 

Now he asks you to write a program that would do this task automatically.

Input

The first line contains the string s consisting of lowercase English letters. The second line contains the string t consisting of lowercase English letters.

The lengths of both string do not exceed 105.

Output

Output a single integer — the number of distinct strings that are concatenations of some non-empty prefix of s with some non-empty prefix of t.

Examples

Input

aba
aa


Output

5


Input

aaaaa
aaaa


Output

8

Note

In the first example, the string s has three non-empty prefixes: {a, ab, aba}. The string t has two non-empty prefixes: {a, aa}. In total, Misha has written five distinct strings: {aa, aaa, aba, abaa, abaaa}. The string abaa has been written twice.

In the second example, Misha has written eight distinct strings: {aa, aaa, aaaa, aaaaa, aaaaaa, aaaaaaa, aaaaaaaa, aaaaaaaaa}.
#include <bits/stdc++.h>
using namespace std;
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char* s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char* s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
inline void readWord(char* s) {
  int c = readChar();
  while (c > 32) *s++ = c, c = getChar();
  *s = 0;
}
inline void writeDouble(double x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  int t = (int)x;
  writeInt(t), x -= t;
  writeChar('.');
  for (int i = output_len - 1; i > 0; i--) {
    x *= 10;
    t = min(9, (int)x);
    writeChar('0' + t), x -= t;
  }
  x *= 10;
  t = min(9, (int)(x + 0.5));
  writeChar('0' + t);
}
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using ull = unsigned long long;
using pnt = complex<ld>;
istream& operator>>(istream& in, pnt& p) {
  ld a, b;
  in >> a >> b;
  p = {a, b};
  return in;
}
ld crs(pnt a, pnt b) { return a.real() * b.imag() - a.imag() * b.real(); }
ld dot(pnt a, pnt b) { return a.real() * b.real() + a.imag() * b.imag(); }
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18L;
const ld pi = acos(-1.0L);
const ld eps = 1e-9L;
const int di[] = {0, 1, -1, 0};
const int dj[] = {1, 0, 0, -1};
const int SQ = 1000;
const int LG = 19;
const int nax = 1e5 + 100;
struct suffixArray {
  struct tup {
    int id, first, second;
    bool operator<(const tup& he) const {
      return first < he.first || first == he.first && second < he.second;
    }
  } a[nax], b[nax];
  int n, K;
  int pw[19];
  int p[19][nax];
  int sa[nax];
  int cnt[nax];
  void init(string& s) {
    pw[0] = 1;
    for (int i = 1; i < 19; i++) pw[i] = 2 * pw[i - 1];
    n = (int)((s).size());
    for (int i = 0; i < n; i++) p[0][i] = s[i] - 'a';
    if (n == 1) p[0][0] = 0;
    K = 1;
    for (int i = 1; pw[i - 1] < n; i++, K++) {
      for (int j = 0; j < n; j++) {
        a[j] = {j, p[i - 1][j],
                j + pw[i - 1] < n ? p[i - 1][j + pw[i - 1]] : -1};
      }
      memset(cnt, 0, sizeof(cnt));
      for (int j = 0; j < n; j++) cnt[a[j].second + 1]++;
      for (int j = 1; j < nax; j++) cnt[j] += cnt[j - 1];
      for (int j = n - 1; j >= 0; j--) b[--cnt[a[j].second + 1]] = a[j];
      memset(cnt, 0, sizeof(cnt));
      for (int j = 0; j < n; j++) cnt[b[j].first]++;
      for (int j = 1; j < nax; j++) cnt[j] += cnt[j - 1];
      for (int j = n - 1; j >= 0; j--) a[--cnt[b[j].first]] = b[j];
      for (int j = 0; j < n; j++) {
        p[i][a[j].id] = (j != 0 && a[j].first == a[j - 1].first &&
                                 a[j].second == a[j - 1].second
                             ? p[i][a[j - 1].id]
                             : j);
      }
    }
    for (int i = 0; i < n; i++) sa[p[K - 1][i]] = i;
  }
  int lcp(int i, int j) {
    if (i == j) return n - i;
    int ret = 0;
    for (int x = K - 1; x >= 0 && i < n && j < n; x--) {
      if (p[x][i] == p[x][j]) {
        ret += pw[x];
        i += pw[x];
        j += pw[x];
      }
    }
    return ret;
  }
};
suffixArray a, b;
struct num {
  static const int MA = 1e9 + 7, MB = 1e9 + 9;
  int a, b;
  num() {}
  num(int x) : a((x % MA + MA) % MA), b((x % MB + MB) % MB) {}
  num(int a, int b) : a((a % MA + MA) % MA), b((b % MB + MB) % MB) {}
  num operator+(const num& he) const { return num(a + he.a, b + he.b); }
  num operator-(const num& he) const { return num(a - he.a, b - he.b); }
  num operator*(const num& he) const {
    return num((ll)a * he.a % MA, (ll)b * he.b % MB);
  }
  bool operator==(const num& he) const { return a == he.a && b == he.b; }
};
mt19937 rnd(322);
int P = max(239, (int)rnd());
num pw[nax];
num ha[nax], hb[nax];
void hinit(string& s, num* h) {
  pw[0] = 1;
  h[0] = 0;
  for (int i = 0; i < (int)((s).size()); i++) {
    pw[i + 1] = pw[i] * P;
    h[i + 1] = h[i] * P + s[i];
  }
}
inline num get(int l, int r, num* h) { return h[r + 1] - h[l] * pw[r - l + 1]; }
string s, t;
int n, m;
inline bool cmp1(int i, int j) {
  int lf = 0, rg = min(n - i, m - j);
  if (get(i, i + rg - 1, ha) == get(j, j + rg - 1, hb)) {
    if (n - i < m - j) return true;
    return false;
  }
  while (lf < rg) {
    int md = (lf + rg + 1) >> 1;
    if (get(i, i + md - 1, ha) == get(j, j + md - 1, hb))
      lf = md;
    else
      rg = md - 1;
  }
  return s[i + lf] < t[j + lf];
}
inline bool cmp2(int i, int j) {
  int lf = 0, rg = min(n - i, m - j);
  if (get(i, i + rg - 1, ha) == get(j, j + rg - 1, hb)) {
    return true;
  }
  while (lf < rg) {
    int md = (lf + rg + 1) >> 1;
    if (get(i, i + md - 1, ha) == get(j, j + md - 1, hb))
      lf = md;
    else
      rg = md - 1;
  }
  return s[i + lf] > t[j + lf];
}
int pfun[nax];
vi g[nax];
pii lr[nax];
ll ans;
bitset<nax> want;
vi qu;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout.precision(8);
  cout << fixed;
  cin >> s >> t;
  swap(s, t);
  n = (int)((s).size()), m = (int)((t).size());
  for (int i = 1; i < n; i++) {
    int k = pfun[i - 1];
    while (k != 0 && s[k] != s[i]) k = pfun[k - 1];
    k += (s[k] == s[i]);
    pfun[i] = k;
  }
  for (int v = 1; v < n; v++) {
    int u = pfun[v] - 1;
    if (u != -1) {
      g[n - 1 - u].push_back(n - 1 - v);
      want[n - (v - u)] = 1;
    }
  }
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  a.init(s);
  b.init(t);
  hinit(s, ha);
  hinit(t, hb);
  qu.reserve(want.count());
  for (int i = 0; i < n; i++)
    if (want[i]) qu.push_back(i);
  sort(qu.begin(), qu.end(),
       [&](int i1, int i2) { return a.p[a.K - 1][i1] < a.p[a.K - 1][i2]; });
  int l = 0, r = -1;
  for (int suf : qu) {
    lr[suf] = make_pair(inf, -inf);
    while (l != m && !cmp1(suf, b.sa[l])) l++;
    while (r != m - 1 && cmp2(suf, b.sa[r + 1])) r++;
    if (l <= r) lr[suf] = make_pair(l, r);
  }
  ans = (ll)n * m;
  for (int v = 0; v < n; v++)
    if (!g[v].empty()) {
      vector<pii> seg;
      for (int to : g[v]) {
        pii ca = lr[n - (v - to)];
        if (ca.first <= ca.second) seg.push_back(ca);
      }
      if (seg.empty()) continue;
      sort(seg.begin(), seg.end());
      int l = seg[0].first, r = seg[0].first;
      for (int i = 0; i < (int)((seg).size()); i++) {
        if (r < seg[i].first) {
          ans -= r - l + 1;
          l = seg[i].first;
        }
        r = max(r, seg[i].second);
      }
      ans -= r - l + 1;
    }
  cout << ans;
}
