#include <bits/stdc++.h>
using namespace std;
char s[1000010], t[1000010];
int sumA[1000010][3][3];
void compute_sums(char* s, int n, int sum[1000010][3][3]) {
  memset(sum, 0, sizeof(sum));
  for (int i = (1); i <= (n); ++i) {
    for (int c = 0; c < (3); ++c)
      for (int d = 0; d < (3); ++d) sum[i][c][d] = sum[i - 1][c][d];
    sum[i][((s[i - 1]) == 'R'   ? 0
            : (s[i - 1]) == 'G' ? 1
                                : 2)][((s[i]) == 'R'   ? 0
                                       : (s[i]) == 'G' ? 1
                                                       : 2)]++;
  }
}
int query(int a, int b, int c, int d, int sum[1000010][3][3]) {
  return (sum[b][c][d] - sum[a - 1][c][d]);
}
int main() {
  scanf("%s%s", s + 1, t + 1);
  s[0] = t[0] = '$';
  int n = strlen(s) - 1;
  int m = strlen(t) - 1;
  compute_sums(t, m, sumA);
  long long ans = 0;
  int first = 1, last = 1;
  int holes = 0;
  for (int i = (1); i <= (n); ++i) {
    if (first > last) break;
    while (last < m && s[i] != t[last]) last++;
    ans += (last - first + 1);
    if (i > 1 && s[i] != s[i - 1])
      holes = query(first, last,
                    ((s[i]) == 'R'   ? 0
                     : (s[i]) == 'G' ? 1
                                     : 2),
                    ((s[i - 1]) == 'R'   ? 0
                     : (s[i - 1]) == 'G' ? 1
                                         : 2),
                    sumA),
      ans -= holes;
    if (s[i] == t[first]) first++;
    if (last < m) last++;
  }
  cout << ans << endl;
}
