#include <bits/stdc++.h>
char s[1000005], t[1000005];
int n, m;
int A[1000005][3][3];
int main(void) {
  scanf("%s%s", s + 1, t + 1);
  n = strlen(s + 1), m = strlen(t + 1);
  for (int i = 1; i <= n; i++) s[i] = s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2);
  for (int i = 1; i <= m; i++) t[i] = t[i] == 'R' ? 0 : (t[i] == 'G' ? 1 : 2);
  s[0] = s[1];
  t[0] = t[1];
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) A[i][j][k] = A[i - 1][j][k];
    if (t[i] != t[i - 1]) A[i][t[i]][t[i - 1]]++;
  }
  int kraj = 0, poc = 0;
  long long sol = 0;
  for (int i = 1; i <= n; i++) {
    if (kraj < m) kraj++;
    while (kraj < m && t[kraj] != s[i]) kraj++;
    sol += (kraj - poc) - (A[kraj][s[i - 1]][s[i]] - A[poc][s[i - 1]][s[i]]);
    if (poc < m && s[i] == t[poc + 1]) poc++;
  }
  printf("%I64d\n", sol);
  return 0;
}
