#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1000010;
char s[2][kMaxN];
int cnt[kMaxN][3][3];
int n, m;
int CH(char c) {
  if (c == 'R') return 0;
  if (c == 'B') return 1;
  return 2;
}
void solve() {
  for (int i = 1; i < m; ++i) {
    memcpy(cnt[i], cnt[i - 1], sizeof(int) * 9);
    ++cnt[i][CH(s[1][i - 1])][CH(s[1][i])];
  }
  long long res = 0;
  int l = 0, r = 0;
  for (int i = 0; i < n && l < m; ++i) {
    for (; r < m - 1 && s[0][i] != s[1][r]; ++r)
      ;
    res += r - l + 1;
    if (0 < i && s[0][i - 1] != s[0][i])
      res -= cnt[r][CH(s[0][i])][CH(s[0][i - 1])] -
             cnt[l][CH(s[0][i])][CH(s[0][i - 1])];
    if (r < m - 1) ++r;
    if (s[1][l] == s[0][i]) ++l;
  }
  printf(
      "%lld"
      "\n",
      res);
}
int main() {
  scanf("%s%s", s[0], s[1]);
  n = strlen(s[0]);
  m = strlen(s[1]);
  solve();
  return 0;
}
