#include <bits/stdc++.h>
inline int in() {
  int k = 0;
  char ch = getchar();
  while (ch < '-') ch = getchar();
  while (ch > '-') k = k * 10 + ch - '0', ch = getchar();
  return k;
}
char s1[1000005], s2[1000005];
int s[1000010][3][3];
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  int n = strlen(s1 + 1), m = strlen(s2 + 1);
  for (int i = 1; i <= n; ++i)
    if (s1[i] == 'R') s1[i] = 'A';
  for (int i = 1; i <= n; ++i)
    if (s1[i] == 'G') s1[i] = 'C';
  for (int i = 1; i <= m; ++i)
    if (s2[i] == 'R') s2[i] = 'A';
  for (int i = 1; i <= m; ++i)
    if (s2[i] == 'G') s2[i] = 'C';
  for (int i = 2; i <= n; ++i) {
    memcpy(s[i], s[i - 1], sizeof s[i]);
    ++s[i][s1[i] - 'A'][s1[i - 1] - 'A'];
  }
  long long ans = 0;
  for (int i = 1, l, r; i <= m; ++i) {
    if (i == 1) {
      l = r = 1;
      while (r < n && s1[r] != s2[i]) ++r;
      ans += r - l + 1;
    } else {
      ++r;
      while (r < n && s1[r] != s2[i]) ++r;
      if (r > n) --r;
      if (s1[l] == s2[i - 1]) ++l;
      if (l > n) break;
      ans += r - l + 1;
      if (s2[i] != s2[i - 1])
        ans -= s[r][s2[i - 1] - 'A'][s2[i] - 'A'] -
               s[l][s2[i - 1] - 'A'][s2[i] - 'A'];
    }
  }
  std::cout << ans << '\n';
  return 0;
}
