#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int n, m, i, j, k;
char a[1000010], b[1000010];
int c[200][200];
long long ans;
int main() {
  for (scanf("%s%s", a, b), n = strlen(a), m = strlen(b), j = 1, i = 0;
       i < n && k < j; i++) {
    for (; a[i] != b[j - 1] && j < m;) c[b[j - 1]][b[j]]++, j++;
    ans += (i == 0 || a[i] == a[i - 1]) ? (j - k) : (j - k - c[a[i]][a[i - 1]]);
    if (a[i] == b[k]) {
      if (j > k + 1) c[b[k]][b[k + 1]]--;
      k++;
    }
    if (j < m) {
      if (j > k) c[b[j - 1]][b[j]]++;
      j++;
    }
  }
  return cout << ans << endl, 0;
}
