#include <bits/stdc++.h>
using namespace std;
const int MxN = 2 * 1e3 + 3;
template <typename T>
void Write(T x) {
  if (x > 9) Write(x / 10);
  putchar(x % 10 + 48);
}
long long ans, dp[MxN][MxN], dpa[MxN][MxN], dpb[MxN][MxN];
map<string, bool> mp;
bitset<MxN> bt;
string s, a, b;
void solve() {
  cin >> s >> a >> b;
  long long n = s.size();
  for (int i = n - 1; ~i; --i)
    for (int j = n - 1; ~j; --j)
      if (s[i] == s[j]) dp[i][j] = dp[i + 1][j + 1] + 1;
  long long na = a.size();
  for (int i = n - 1; ~i; --i)
    for (int j = na - 1; ~j; --j)
      if (s[i] == a[j]) dpa[i][j] = dpa[i + 1][j + 1] + 1;
  long long nb = b.size();
  for (int i = n - 1; ~i; --i)
    for (int j = nb - 1; ~j; --j)
      if (s[i] == b[j]) dpb[i][j] = dpb[i + 1][j + 1] + 1;
  for (int i = 0; i < n; ++i) {
    long long mx = max(na, nb) - 1;
    for (int j = 0; j < i; ++j) mx = max(dp[i][j], mx);
    for (int j = i + mx; j < n; ++j)
      if (dpa[i][0] == na && dpb[j - nb + 1][0] == nb) ans++;
  }
  printf("%lld", ans);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  solve();
}
