#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int ls, lt;
string s, t;
int st, mid, ed;
int sum[MAXN][3][3];
int color(char p) {
  if (p == 'R')
    return 0;
  else if (p == 'G')
    return 1;
  else
    return 2;
}
int main() {
  cin >> s >> t;
  ls = s.size(), lt = t.size();
  long long ans = 1;
  st = 0, ed = 1;
  while (ed < lt && t[ed - 1] != s[0]) {
    ed++;
    ans++;
  }
  mid = ed;
  for (int i = 1; i < lt; ++i) sum[i][color(t[i - 1])][color(t[i])]++;
  for (int i = 1; i <= lt; ++i)
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k) sum[i][j][k] += sum[i - 1][j][k];
  for (int i = 2; i <= ls; ++i) {
    if (ed < lt && t[ed - 1] == s[i - 2]) ed++;
    while (ed < lt) {
      if (t[ed - 1] != s[i - 1])
        ed++;
      else
        break;
    }
    if (t[st] == s[i - 2]) st++;
    while (st < ed) {
      if (t[st] != s[i - 2] || t[st - 1] == s[i - 2])
        break;
      else
        st++;
    }
    if (s[i - 1] != s[i - 2])
      ans += ed - st - sum[ed - 1][color(s[i - 1])][color(s[i - 2])] +
             sum[st][color(s[i - 1])][color(s[i - 2])];
    else
      ans += ed - st;
    if (ed == st) break;
  }
  cout << ans << endl;
  return 0;
}
