#include <bits/stdc++.h>
const int N = 1000000;
char s[N + 1], t[N + 1];
int amt[N][3][3];
int f(char ch) {
  if (ch == 'R') return 0;
  if (ch == 'G') return 1;
  return 2;
}
int main() {
  scanf("%s%s", s, t);
  for (int i = 1; t[i]; ++i) {
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k) amt[i][j][k] = amt[i - 1][j][k];
    ++amt[i][f(t[i - 1])][f(t[i])];
  }
  long long ans = 0;
  for (int i = 0, j = 0, k = 0; s[i]; ++i) {
    while (t[j] && s[i] != t[j]) ++j;
    if (t[j]) ++j;
    if (i && t[k] && s[i - 1] == t[k]) ++k;
    if (t[k])
      ans += j - k -
             (i && s[i] != s[i - 1] ? amt[j - 1][f(s[i])][f(s[i - 1])] -
                                          amt[k][f(s[i])][f(s[i - 1])]
                                    : 0);
  }
  printf("%lld\n", ans);
  return 0;
}
