#include <bits/stdc++.h>
using namespace std;
template <class T>
void in(T &x) {
  x = 0;
  bool f = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  if (f) x = -x;
}
char tc[1000005];
int a[1000005], b[1000005];
int n, m;
int sum[1000005][3][3];
signed main() {
  scanf("%s", tc + 1);
  n = strlen(tc + 1);
  for (register int i = 1; i <= n; ++i)
    a[i] = (tc[i] == 'R' ? 0 : (tc[i] == 'G' ? 1 : 2));
  scanf("%s", tc + 1);
  m = strlen(tc + 1);
  for (register int i = 1; i <= m; ++i)
    b[i] = (tc[i] == 'R' ? 0 : (tc[i] == 'G' ? 1 : 2));
  for (register int i = 2; i <= m; ++i) {
    for (register int j = 0; j < 3; ++j)
      for (register int k = 0; k < 3; ++k) sum[i][j][k] = sum[i - 1][j][k];
    ++sum[i][b[i - 1]][b[i]];
  }
  int l = 1, r = 0;
  long long ans = 0;
  for (register int i = 1; i <= n; ++i) {
    ++r;
    while (r < m && b[r] != a[i]) ++r;
    if (r > m) r = m;
    if (i > 1 && b[l] == a[i - 1]) ++l;
    if (l > m) break;
    ans += r - l + 1;
    if (i > 1 && a[i] != a[i - 1])
      ans -= sum[r][a[i]][a[i - 1]] - sum[l - 1][a[i]][a[i - 1]];
  }
  printf("%lld", ans);
  return 0;
}
