#include <bits/stdc++.h>
using namespace std;
int n, m, sum[1000100][3][3];
long long ans;
char a[1000100], b[1000100];
int num(char c) {
  if (c == 'R') return 0;
  if (c == 'G') return 1;
  return 2;
}
int main() {
  scanf("%s%s", a + 1, b + 1), n = strlen(a + 1), m = strlen(b + 1);
  for (int i = 2; i <= m; ++i) {
    memcpy(sum[i], sum[i - 1], sizeof(sum[i]));
    ++sum[i][num(b[i - 1])][num(b[i])];
  }
  for (int i = 1, l = 1, r = 1; i <= n && l <= m; ++i) {
    for (; r < m && a[i] != b[r]; ++r)
      ;
    ans += r - l + 1;
    if (i > 1 && a[i] != a[i - 1])
      ans -=
          sum[r][num(a[i])][num(a[i - 1])] - sum[l][num(a[i])][num(a[i - 1])];
    l += a[i] == b[l], r += r < m;
  }
  printf("%I64d\n", ans);
  return 0;
}
