#include <bits/stdc++.h>
using namespace std;
char s[1000010], t[1000010];
int ls, lt;
int sum[1000010][3][3];
int main() {
  scanf("%s%s", s + 1, t + 1);
  ls = strlen(s + 1);
  lt = strlen(t + 1);
  if (ls > lt) {
    swap(ls, lt);
    swap(s, t);
  }
  for (int i = 1; i <= ls; ++i) {
    if (s[i] == 'R') s[i] = 0;
    if (s[i] == 'G') s[i] = 1;
    if (s[i] == 'B') s[i] = 2;
  }
  for (int i = 1; i <= lt; ++i) {
    if (t[i] == 'R') t[i] = 0;
    if (t[i] == 'G') t[i] = 1;
    if (t[i] == 'B') t[i] = 2;
  }
  long long ans = 0;
  int l = 1, r = 1;
  while (r < lt && t[r] != s[1]) {
    ++r;
    for (int j1 = 0; j1 < 3; ++j1)
      for (int j2 = 0; j2 < 3; ++j2) sum[r][j1][j2] = sum[r - 1][j1][j2];
    ++sum[r][t[r - 1]][t[r]];
  }
  for (int i = 1; i <= ls; ++i) {
    while (r < lt && t[r] != s[i]) {
      ++r;
      for (int j1 = 0; j1 < 3; ++j1)
        for (int j2 = 0; j2 < 3; ++j2) sum[r][j1][j2] = sum[r - 1][j1][j2];
      ++sum[r][t[r - 1]][t[r]];
    }
    ans += r - l + 1;
    if (s[i] != s[i - 1])
      ans -= sum[r][s[i]][s[i - 1]] - sum[l - 1][s[i]][s[i - 1]];
    if (s[i] == t[l]) ++l;
    if (r < lt) {
      ++r;
      for (int j1 = 0; j1 < 3; ++j1)
        for (int j2 = 0; j2 < 3; ++j2) sum[r][j1][j2] = sum[r - 1][j1][j2];
      ++sum[r][t[r - 1]][t[r]];
    }
  }
  cout << ans << endl;
  return 0;
}
