#include <bits/stdc++.h>
using namespace std;
void compute_lcps(char* A, int n, char* B, int m, int nextB[1000010][3],
                  int* res) {
  res[0] = 0;
  for (int i = (1); i <= (n); ++i)
    res[i] = nextB[res[i - 1]][((A[i]) == 'R' ? 0 : (A[i]) == 'G' ? 1 : 2)];
}
void compute_next(char* A, int n, int res[1000010][3]) {
  int last[3];
  for (int i = 0; i < (3); ++i) last[i] = 1000010 - 1;
  for (int i = 0; i < (1000010); ++i)
    for (int c = 0; c < (3); ++c) res[i][c] = 1000010 - 1;
  for (int i = (n); i >= (0); --i) {
    for (int c = 0; c < (3); ++c) res[i][c] = last[c];
    if (i) last[((A[i]) == 'R' ? 0 : (A[i]) == 'G' ? 1 : 2)] = i;
  }
}
void compute_sums(char* A, int n, int res[1000010][3][3]) {
  memset(res, 0, sizeof(res));
  for (int i = (2); i <= (n); ++i) {
    for (int c = 0; c < (3); ++c)
      for (int d = 0; d < (3); ++d) res[i][c][d] = res[i - 1][c][d];
    res[i][((A[i - 1]) == 'R'   ? 0
            : (A[i - 1]) == 'G' ? 1
                                : 2)][((A[i]) == 'R'   ? 0
                                       : (A[i]) == 'G' ? 1
                                                       : 2)]++;
  }
}
char A[1000010];
char B[1000010];
int nextA[1000010][3];
int nextB[1000010][3];
int dpA[1000010];
int dpB[1000010];
int sumA[1000010][3][3];
int sumB[1000010][3][3];
int earl(int j, int* dp, int n) {
  return (upper_bound(dp + 1, dp + 1 + n, j - 1) - dp - 1);
}
int farl(int j, int* dpB, int m) { return dpB[j] - 1; }
int query(int i, int j, int c, int d, int sum[1000010][3][3]) {
  return sum[j][c][d] - sum[i - 1][c][d];
}
int realans(char* A, char* B) {
  int n = strlen(A) - 1;
  int m = strlen(B) - 1;
  set<pair<int, int> > res;
  queue<pair<int, int> > Q;
  Q.push(make_pair(1, 1));
  while (!Q.empty()) {
    pair<int, int> p = Q.front();
    Q.pop();
    if (res.find(p) != res.end()) continue;
    res.insert(p);
    int i = p.first, j = p.second;
    if (i < n && A[i] != B[j]) Q.push(make_pair(i + 1, j));
    if (j < m && A[i] != B[j]) Q.push(make_pair(i, j + 1));
    if (i < n && j < m && A[i] == B[j]) Q.push(make_pair(i + 1, j + 1));
  }
  return res.size();
}
int main() {
  srand(time(NULL));
  scanf("%s%s", A + 1, B + 1);
  A[0] = B[0] = '$';
  int n = strlen(A) - 1;
  int m = strlen(B) - 1;
  compute_next(A, n, nextA);
  compute_next(B, m, nextB);
  compute_lcps(A, n, B, m, nextB, dpA);
  compute_lcps(B, m, A, n, nextA, dpB);
  compute_sums(A, n, sumA);
  long long ans = 0;
  for (int j = (1); j <= (m); ++j) {
    int i1 = earl(j, dpA, n);
    int i2 = min(farl(j, dpB, m), n - 1);
    int cnt = (i2 - i1 + 1);
    int holes = 0;
    if (j > 1 && B[j] != B[j - 1])
      holes = query(i1 + 1, i2 + 1,
                    ((B[j]) == 'R'   ? 0
                     : (B[j]) == 'G' ? 1
                                     : 2),
                    ((B[j - 1]) == 'R'   ? 0
                     : (B[j - 1]) == 'G' ? 1
                                         : 2),
                    sumA),
      cnt -= holes;
    ans += cnt;
  }
  cout << ans << endl;
}
