#include <bits/stdc++.h>
using namespace std;
template <class T>
void tension(T& a, const T& b) {
  if (b < a) a = b;
}
const int MAXN = (int)1e6 + 3;
int n, m;
char s[MAXN], t[MAXN];
void init(char* const s, int n, char* const t, int m, int* const ret) {
  for (int i = 1; i <= n; i++) {
    ret[i] = ret[i - 1] + 1;
    while (ret[i] < m && t[ret[i]] != s[i]) ret[i]++;
    tension(ret[i], m);
  }
}
int main() {
  scanf("%s\n%s\n", s + 1, t + 1);
  static int p1[MAXN], p2[MAXN];
  n = strlen(s + 1);
  m = strlen(t + 1);
  init(s, n, t, m, p1);
  init(t, m, s, n, p2);
  static int sum[MAXN][3][3];
  for (int i = 2; i <= m; i++) {
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) {
        if ((t[i - 1] == 'R' ? 0 : (t[i - 1] == 'G' ? 1 : 2)) == j &&
            (t[i] == 'R' ? 0 : (t[i] == 'G' ? 1 : 2)) == k)
          sum[i][j][k] = sum[i - 1][j][k] + 1;
        else
          sum[i][j][k] = sum[i - 1][j][k];
      }
  }
  long long ans = 0;
  int L = 1;
  for (int i = 1; i <= n; i++) {
    int R = p1[i];
    while (L <= m && p2[L] < i) L++;
    ans += max(R - L + 1, 0);
    if (L <= R && i > 1) {
      int j = (s[i - 1] == 'R' ? 0 : (s[i - 1] == 'G' ? 1 : 2));
      int k = (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2));
      if (j != k) {
        ans -= sum[R][k][j];
        ans += sum[L - 1][k][j];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
