#include <bits/stdc++.h>
using namespace std;
long long ans;
int a[1000005], b[1000005], s[1000005][3][3], i, l, r, n, m;
char st[1000005];
int main() {
  scanf("%s", st + 1);
  for (i = 1; st[i]; i++) a[i] = st[i] == 'R' ? 0 : st[i] == 'G' ? 1 : 2;
  n = i - 1;
  scanf("%s", st + 1);
  for (i = 1; st[i]; i++) b[i] = st[i] == 'R' ? 0 : st[i] == 'G' ? 1 : 2;
  m = i - 1;
  for (i = 2; i <= n; i++)
    memcpy(s[i], s[i - 1], sizeof(s[i])), s[i][a[i - 1]][a[i]]++;
  l = r = 1;
  for (i = 1; i <= m && l <= n; i++) {
    for (; a[r] != b[i] && r < n; r++)
      ;
    ans += r - l + 1;
    if (i != m && b[i] != b[i + 1])
      ans -= s[r][b[i + 1]][b[i]] - s[l][b[i + 1]][b[i]];
    if (r < n) r++;
    if (a[l] == b[i]) l++;
  }
  printf("%I64d", ans);
  return 0;
}
