#include <bits/stdc++.h>
using namespace std;
namespace yspm {
inline long long read() {
  long long res = 0, f = 1;
  char k;
  while (!isdigit(k = getchar()))
    if (k == '-') f = -1;
  while (isdigit(k)) res = res * 10 + k - '0', k = getchar();
  return res * f;
}
const long long N = 1e6 + 10;
inline long long turn(char id1, char id2) {
  long long p1 = id1 - 'A', p2 = id2 - 'A';
  return (p1 > p2 ? 4 : 0) + p1 + p2;
}
char s1[N], s2[N];
long long f[N][8];
inline void change(char &p) {
  if (p == 'B')
    p = 'A';
  else if (p == 'G')
    p = 'B';
  else
    p = 'C';
  return;
}
signed main() {
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  long long l1 = strlen(s1 + 1), l2 = strlen(s2 + 1);
  for (register long long i = 1; i <= l1; ++i) change(s1[i]);
  for (register long long i = 1; i <= l2; ++i) change(s2[i]);
  for (register long long i = 2; i <= l1; ++i) {
    for (register long long j = 0; j < 8; ++j) f[i][j] = f[i - 1][j];
    if (s1[i] == s1[i - 1]) continue;
    f[i][turn(s1[i - 1], s1[i])]++;
  }
  for (register long long j = 0; j < 8; ++j) f[l1 + 1][j] = f[l1][j];
  long long l = 1, r = 1, ans = 0;
  for (register long long i = 1; i <= l2; ++i) {
    if (i != 1 && s2[i] != s2[i - 1]) {
      long long p = turn(s2[i], s2[i - 1]);
      ans -= f[r][p] - f[l][p];
    }
    while (s1[r] != s2[i] && r <= l1) ++r;
    ans += r - l + 1 - (r == l1 + 1);
    if (r <= l1) ++r;
    if (s1[l] == s2[i] && l < r) ++l;
  }
  printf("%lld\n", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
}  // namespace yspm
signed main() { return yspm::main(); }
