#include <bits/stdc++.h>
using namespace std;
int decode(char s) {
  if (s == 'R') return 0;
  if (s == 'G') return 1;
  return 2;
}
int dp[1000100][3][3];
char s[1000100];
char t[1000100];
int main() {
  scanf("%s %s", s + 1, t + 1);
  int n = strlen(s + 1);
  int m = strlen(t + 1);
  s[0] = t[0] = 'R';
  for (int i = 2; i <= m; i++) {
    for (int ii = 0; ii < 3; ii++)
      for (int jj = 0; jj < 3; jj++) dp[i][ii][jj] = dp[i - 1][ii][jj];
    dp[i][decode(t[i - 1])][decode(t[i])]++;
  }
  int st = 0, ed = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (t[st] == s[i - 1]) st++;
    if (st > m) break;
    ed++;
    while (ed + 1 <= m and s[i] != t[ed]) ed++;
    if (ed > m) ed--;
    ans += (ed - st + 1);
    if (i > 1 and s[i] != s[i - 1])
      ans -= (dp[ed][decode(s[i])][decode(s[i - 1])] -
              dp[st][decode(s[i])][decode(s[i - 1])]);
  }
  printf("%I64d\n", ans);
}
