#include <bits/stdc++.h>
using namespace std;
long long pow(long long b, long long e, long long m) {
  long long t = 1;
  for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
  return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
T gcd(T x, T y) {
  for (T t; x; t = x, x = y % x, y = t)
    ;
  return y;
}
template <class edge>
struct Graph {
  vector<vector<edge> > adj;
  Graph(int n) {
    adj.clear();
    adj.resize(n + 5);
  }
  Graph() { adj.clear(); }
  void resize(int n) { adj.resize(n + 5); }
  void add(int s, edge e) { adj[s].push_back(e); }
  void del(int s, edge e) { adj[s].erase(find(iter(adj[s]), e)); }
  vector<edge> &operator[](int t) { return adj[t]; }
};
string S, T;
map<pair<char, char>, int> f;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> S >> T;
  int n = (int)((S).size()), m = (int)((T).size()), L = 0, R = 0;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (; R < m - 1 && T[R] != S[i]; ++R) ++f[make_pair(T[R], T[R + 1])];
    ans += R - L + 1;
    if (i < n - 1 && S[i] != S[i + 1]) ans -= f[make_pair(S[i + 1], S[i])];
    if (T[L] == S[i]) --f[make_pair(T[L], T[L + 1])], ++L;
    if (R < m - 1) ++f[make_pair(T[R], T[R + 1])], ++R;
    if (L == m) break;
  }
  cout << ans << endl;
  return 0;
}
