#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int N = 1e6 + 100;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long long inf = 8e18;
const int LOG = 22;
long long pw(long long a, long long b, long long M) {
  return (!b ? 1
             : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M
                      : pw(a * a % M, b / 2, M)));
}
char s[N], t[N];
int ps[N][4][4], A[N], B[N];
int find(char c) {
  if (c == 'R')
    return 0;
  else if (c == 'G')
    return 1;
  return 2;
}
int calc(int i, int j) {
  if (i < 0 || j == 0) return 0;
  return ps[i][A[j]][A[j - 1]];
}
int main() {
  scanf("%s%s", s, t);
  int n = strlen(s), m = strlen(t);
  for (int i = 0; i < n; i++) {
    A[i] = find(s[i]);
  }
  for (int i = 0; i < m; i++) {
    B[i] = find(t[i]);
  }
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        ps[i][j][k] = ps[i - 1][j][k];
      }
    }
    if (B[i] != B[i - 1]) ps[i][B[i - 1]][B[i]]++;
  }
  int tl = 0, tr = 0;
  long long tot = 0;
  for (int i = 0; i < n; i++) {
    while (tr < m - 1 && s[i] != t[tr]) tr++;
    tot += tr - tl + 1 - calc(tr, i) + calc(tl - 1, i);
    if (t[tl] == s[i]) tl++;
    if (tr < m - 1) tr++;
  }
  printf("%lld", tot);
  return 0;
}
