#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
string s1, s2;
int n, m;
long long dp[maxn][3][3];
int p1[maxn], p2[maxn];
int f(char a) { return a == 'G' ? 0 : (a == 'R' ? 1 : 2); }
void init(const string s, int n, const string t, int m, int p[]) {
  p[0] = 0;
  while (p[0] < m && s[0] != t[p[0]]) p[0]++;
  p[0] = min(p[0], m - 1);
  for (int i = 1; i < n; i++) {
    p[i] = p[i - 1] + 1;
    while (p[i] < m && s[i] != t[p[i]]) p[i]++;
    p[i] = min(p[i], m - 1);
  }
}
int main() {
  cin >> s1;
  cin >> s2;
  n = s1.size();
  m = s2.size();
  init(s1, n, s2, m, p1);
  init(s2, m, s1, n, p2);
  memset(dp, 0ll, sizeof(dp));
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (f(s2[i - 1]) == j && f(s2[i]) == k)
          dp[i][j][k] = dp[i - 1][j][k] + 1;
        else
          dp[i][j][k] = dp[i - 1][j][k];
      }
    }
  }
  long long ret = 0;
  int l = 0, r;
  for (int i = 0; i < n; i++) {
    r = p1[i];
    while (l < m && p2[l] < i) l++;
    ret += max(r - l + 1, 0);
    if (i && l <= r) {
      int j = f(s1[i - 1]), k = f(s1[i]);
      if (j != k) {
        ret -= dp[r][k][j];
        if (l - 1 >= 0) ret += dp[l - 1][k][j];
      }
    }
  }
  cout << ret << endl;
  return 0;
}
