#include <bits/stdc++.h>
using namespace std;
const int _ = 1000005;
inline int read() {
  char ch = '!';
  int z = 1, num = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') z = -1, ch = getchar();
  while (ch <= '9' && ch >= '0')
    num = (num << 3) + (num << 1) + ch - '0', ch = getchar();
  return z * num;
}
int n, m, nxt[3][3][_], l[_], r[_];
char s1[_], s2[_];
long long ans;
int main() {
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  n = strlen(s1 + 1);
  m = strlen(s2 + 1);
  for (int i = 1; i <= n; ++i) {
    if (s1[i] == 'R') s1[i] = 'A';
    if (s1[i] == 'G') s1[i] = 'C';
  }
  for (int i = 1; i <= m; ++i) {
    if (s2[i] == 'R') s2[i] = 'A';
    if (s2[i] == 'G') s2[i] = 'C';
  }
  if (n > m) swap(n, m), swap(s1, s2);
  for (int j = 1, i = 1; i <= n; ++i) {
    while (j < m && s2[j] != s1[i]) ++j;
    r[i] = j++;
    j = min(j, m);
  }
  for (int j = 1, i = 1; i <= m; ++i) {
    while (j < n && s1[j] != s2[i]) l[j++] = i;
    l[j++] = i;
    if (j > n) break;
  }
  for (int i = 2; i <= m; ++i) {
    nxt[s2[i - 1] - 'A'][s2[i] - 'A'][i] = 1;
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k) nxt[j][k][i] += nxt[j][k][i - 1];
  }
  for (int i = 1; i <= n; ++i) {
    ans += r[i] - l[i] + 1;
    if (i == 1 || (s1[i] == s1[i - 1])) continue;
    int tmp = nxt[s1[i] - 'A'][s1[i - 1] - 'A'][r[i]] -
              nxt[s1[i] - 'A'][s1[i - 1] - 'A'][l[i]];
    ans -= tmp;
  }
  printf("%lld\n", ans);
  return 0;
}
