#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
const int maxn = 1200000;
char s1[maxn], s2[maxn];
long long ans;
int l[maxn], r[maxn], s[9][maxn];
inline int h(char c) {
  if (c == 'R')
    return 0;
  else if (c == 'G')
    return 1;
  else
    return 2;
}
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  int l1 = strlen(s1 + 1), l2 = strlen(s2 + 1);
  l[1] = 0;
  for (int i = (2); i <= (l1); ++i) {
    l[i] = l[i - 1];
    while (l[i] + 1 < i && (s1[i - 1] == s2[l[i] + 1] &&
                            (l[i] == l[i - 1] || s1[i - 1] != s2[l[i]])))
      l[i]++;
  }
  r[1] = 1;
  for (int i = (1); i <= (l1); ++i) {
    while (r[i] < l2 && s1[i] != s2[r[i]]) r[i]++;
    r[i + 1] = min(l2, r[i] + 1);
  }
  for (int i = (2); i <= (l2); ++i)
    if (s2[i] != s2[i - 1]) s[h(s2[i - 1]) * 3 + h(s2[i])][i] = 1;
  for (int i = (0); i < (9); ++i)
    for (int j = (1); j <= (l2); ++j) s[i][j] += s[i][j - 1];
  ans = (long long)l1 * l2;
  ans -= l2 - r[1];
  for (int i = (2); i <= (l1); ++i) {
    ans -= l[i];
    ans -= l2 - r[i];
    int t = h(s1[i]) * 3 + h(s1[i - 1]);
    if (r[i] > l[i] + 1) ans -= s[t][r[i]] - s[t][l[i] + 1];
  }
  printf("%lld\n", ans);
  return 0;
}
