#include <bits/stdc++.h>
using namespace std;
char c[1000010], s[1000010];
int a[1000010][3][3];
int main() {
  int i, n, m, p, q;
  long long ans = 0;
  scanf("%s%s", c, s);
  n = strlen(c);
  m = strlen(s);
  for (i = 0; i < n; i++) {
    if (c[i] == 'R')
      c[i] = 0;
    else if (c[i] == 'G')
      c[i] = 1;
    else
      c[i] = 2;
  }
  for (i = 0; i < m; i++) {
    if (s[i] == 'R')
      s[i] = 0;
    else if (s[i] == 'G')
      s[i] = 1;
    else
      s[i] = 2;
  }
  for (i = 1; i < m; i++) {
    for (int x = 0; x < 3; x++) {
      for (int y = 0; y < 3; y++) {
        a[i + 1][x][y] = a[i][x][y];
      }
    }
    a[i + 1][s[i - 1]][s[i]]++;
  }
  for (int x = 0; x < 3; x++) {
    for (int y = 0; y < 3; y++) {
      a[i + 1][x][y] = a[i][x][y];
    }
  }
  p = q = 0;
  for (i = 0; i < n; i++) {
    while (q < m - 1 && s[q] != c[i]) q++;
    if (p == m) break;
    ans += (q - p + 1);
    if (i && c[i] != c[i - 1]) {
      ans -= a[q + 1][c[i]][c[i - 1]];
      ans += a[p + 1][c[i]][c[i - 1]];
    }
    if (p < m && s[p] == c[i]) p++;
    if (q < m - 1 && s[q] == c[i]) q++;
  }
  printf("%I64d\n", ans);
  return 0;
}
