#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
char s1[maxn], s2[maxn];
int m, n, ann, flag;
int f[7][maxn], sum[7][maxn];
int a[maxn], b[maxn];
long long ans;
int lou(char c) {
  if (c == 'R') return 1;
  if (c == 'G') return 2;
  if (c == 'B') return 3;
}
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  m = strlen(s1);
  n = strlen(s2);
  for (int i = 1; i <= m; i++) a[i] = lou(s1[i - 1]);
  for (int i = 1; i <= n; i++) b[i] = lou(s2[i - 1]);
  memset(f, 0, sizeof(f));
  memset(sum, 0, sizeof(sum));
  for (int i = 2; i <= n; i++) {
    if ((b[i - 1] == 1) && (b[i] == 2)) ++f[1][i];
    if ((b[i - 1] == 1) && (b[i] == 3)) ++f[2][i];
    if ((b[i - 1] == 2) && (b[i] == 1)) ++f[3][i];
    if ((b[i - 1] == 2) && (b[i] == 3)) ++f[4][i];
    if ((b[i - 1] == 3) && (b[i] == 1)) ++f[5][i];
    if ((b[i - 1] == 3) && (b[i] == 2)) ++f[6][i];
  }
  for (int i = 1; i <= 6; i++) {
    sum[i][1] = 0;
    for (int j = 2; j <= n; j++) sum[i][j] = sum[i][j - 1] + f[i][j];
  }
  int left = 1, right = 1;
  ans = 0;
  for (int i = 1; i <= m; i++) {
    if (i == 1)
      ann == -1;
    else
      ann = a[i - 1];
    if (b[left] == ann) ++left;
    if (b[right] == ann) ++right;
    if (right > n) right = n;
    while ((right < n) && (b[right] != a[i])) ++right;
    if (left <= right) {
      ans += (long long)right - left + 1;
      flag = -1;
      if ((a[i] == 1) && (a[i - 1] == 2)) flag = 1;
      if ((a[i] == 1) && (a[i - 1] == 3)) flag = 2;
      if ((a[i] == 2) && (a[i - 1] == 1)) flag = 3;
      if ((a[i] == 2) && (a[i - 1] == 3)) flag = 4;
      if ((a[i] == 3) && (a[i - 1] == 1)) flag = 5;
      if ((a[i] == 3) && (a[i - 1] == 2)) flag = 6;
      if (flag != -1) ans -= (long long)sum[flag][right] - sum[flag][left - 1];
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
