#include <bits/stdc++.h>
using namespace std;
char str1[1111111], str2[1111111];
int f1[1111111], f2[1111111];
int calc[1111111][3][3];
long long ans;
int trans(char ch) {
  if (ch == 'G') return 0;
  if (ch == 'B') return 1;
  return 2;
}
int l, r;
int main() {
  scanf(" %s", str1 + 1);
  scanf(" %s", str2 + 1);
  l = r = 1;
  int len1 = strlen(str1 + 1);
  int len2 = strlen(str2 + 1);
  for (int i = 1; i <= len1; i++) f1[i] = trans(str1[i]);
  for (int i = 1; i <= len2; i++) f2[i] = trans(str2[i]);
  long long ans = 0;
  for (int i = 2; i <= len2; i++) {
    for (int j = 0; j <= 2; j++)
      for (int k = 0; k <= 2; k++) calc[i][j][k] = calc[i - 1][j][k];
    calc[i][f2[i]][f2[i - 1]]++;
  }
  for (int i = 1; i <= len1; i++) {
    while (r != len2 && f1[i] != f2[r]) r++;
    ans += (r - l + 1);
    if (i != 1 && f1[i] != f1[i - 1])
      ans -= calc[r][f1[i - 1]][f1[i]] - calc[l][f1[i - 1]][f1[i]];
    if (f1[i] == f2[l]) l++;
    if (l > len2) break;
    if (r != len2 && f1[i] == f2[r]) r++;
  }
  cout << ans << endl;
}
