#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 15;
char a[maxn], b[maxn];
int zh[maxn];
int tj[maxn][3][3];
int la, lb;
int main() {
  scanf("%s", a);
  scanf("%s", b);
  la = strlen(a);
  lb = strlen(b);
  zh['R'] = 0;
  zh['G'] = 1;
  zh['B'] = 2;
  for (int i = 1; i < lb; i++) tj[i][zh[b[i - 1]]][zh[b[i]]] = 1;
  for (int i = 1; i < lb; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) tj[i][j][k] += tj[i - 1][j][k];
  long long ans = 0;
  for (int i = 0, l = 0, r = 0; i < la && l < lb; i++) {
    for (; r < lb - 1 && b[r] != a[i]; r++)
      ;
    ans += r - l + 1;
    if (a[i] != a[i + 1] && i < la - 1)
      ans -= tj[r][zh[a[i + 1]]][zh[a[i]]] - tj[l][zh[a[i + 1]]][zh[a[i]]];
    if (b[l] == a[i]) l++;
    if (r < lb - 1) r++;
  }
  printf("%I64d\n", ans);
  return 0;
}
