#include <bits/stdc++.h>
using namespace std;
int la, lb;
long long ans = 0;
int l, r;
char str[1010000];
int a[1010000], b[1010000];
int sum[1010000][3][3];
int main() {
  scanf("%s", str + 1);
  la = strlen(str + 1);
  l = r = 1;
  for (int i = (1); i <= (la); i++)
    if (str[i] == 'R')
      a[i] = 1;
    else if (str[i] == 'B')
      a[i] = 2;
  scanf("%s", str + 1);
  lb = strlen(str + 1);
  for (int i = (1); i <= (lb); i++)
    if (str[i] == 'R')
      b[i] = 1;
    else if (str[i] == 'B')
      b[i] = 2;
  for (int i = (2); i <= (lb); i++) {
    for (int j = (0); j <= (2); j++)
      for (int k = (0); k <= (2); k++) sum[i][j][k] = sum[i - 1][j][k];
    sum[i][b[i - 1]][b[i]]++;
  }
  for (int i = (1); i <= (la); i++) {
    while (r < lb && b[r] != a[i]) r++;
    ans += 1ll * (r - l + 1);
    if (i > 1 && l <= lb && (a[i] ^ a[i - 1]))
      ans -= 1ll * (sum[r][a[i]][a[i - 1]] - sum[l][a[i]][a[i - 1]]);
    if (l <= lb && a[i] == b[l]) l++;
    if (r < lb && b[r] == a[i]) r++;
  }
  printf("%I64d\n", ans);
  return 0;
}
