#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
char s[N], t[N];
int a[26];
int sums[N][3][3], sumt[N][3][3];
int n, m;
long long ans;
int main() {
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  n = strlen(s + 1);
  m = strlen(t + 1);
  a['R' - 'A'] = 0;
  a['B' - 'A'] = 1;
  a['G' - 'A'] = 2;
  memset(sums, 0, sizeof(sums));
  memset(sumt, 0, sizeof(sumt));
  for (int i = n; i >= 2; i--) {
    memcpy(sums[i], sums[i + 1], sizeof(sums[i]));
    sums[i][a[s[i] - 'A']][a[s[i - 1] - 'A']]++;
  }
  for (int i = 2; i <= m; i++) {
    memcpy(sumt[i], sumt[i - 1], sizeof(sumt[i]));
    sumt[i][a[t[i] - 'A']][a[t[i - 1] - 'A']]++;
  }
  int j = 0;
  ans = 0;
  for (int i = 1; i <= n; i++) {
    for (; j < m - 1 && t[j + 1] != s[i]; j++)
      ;
    ans += j + 1;
    if (i >= 2 && s[i] != s[i - 1])
      ans -= sumt[j + 1][a[s[i - 1] - 'A']][a[s[i] - 'A']];
    if (j < m - 1) j++;
  }
  j = 0;
  for (int i = 1; i <= m; i++) {
    for (; j < n - 1 && s[j + 1] != t[i]; j++)
      ;
    ans -= n - j - 1;
    if (i >= 2 && t[i] != t[i - 1])
      ans += sums[j + 2][a[t[i - 1] - 'A']][a[t[i] - 'A']];
    if (j < n - 1) j++;
  }
  printf("%I64d\n", ans);
  return 0;
}
