#include <bits/stdc++.h>
const int n = 1000005;
long long Ans;
int L1, L2, i, l, r;
char S1[n], S2[n];
int A[n], B[n], C[n][5][5];
int Change(char x) {
  if (x == 'R') return 0;
  if (x == 'G') return 1;
  return 2;
}
int main() {
  scanf("%s%s", S1, S2);
  L1 = strlen(S1), L2 = strlen(S2);
  for (i = 1; i <= L1; ++i) A[i] = Change(S1[i - 1]);
  for (i = 1; i <= L2; ++i) B[i] = Change(S2[i - 1]);
  for (i = 1; i < L2; ++i) {
    memcpy(C[i + 1], C[i], sizeof(C[i + 1]));
    C[i + 1][B[i]][B[i + 1]] += (B[i] != B[i + 1]);
  }
  for (i = l = r = 1; i <= L1 && l <= L2; ++i) {
    for (; B[r] != A[i] && r < L2; ++r)
      ;
    Ans += r - l + 1;
    if (i + 1 <= L1) Ans -= C[r][A[i + 1]][A[i]] - C[l][A[i + 1]][A[i]];
    r += (r < L2);
    l += (B[l] == A[i]);
  }
  printf("%I64d\n", Ans);
  return 0;
}
