#include <bits/stdc++.h>
using namespace std;
const int iinf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int N = 500000, mN = N * 3;
int n, m;
string a, b, t, nt;
int za[mN], zb[mN], *fa, *fb;
void zfun(string s, int* z) {
  int l = 0;
  for (int i = (1), I = (int((s).size())); i < I; i++) {
    if (l + z[l] > i) z[i] = min(l + z[l] - i, z[i - l]);
    while (i + z[i] < int((s).size()) && s[z[i]] == s[i + z[i]]) z[i]++;
    if (i + z[i] > l + z[l]) l = i;
  }
}
long long c[mN], cx[mN];
void add(int first, long long v) {
  for (int i = first; i < mN; i |= (i + 1)) c[i] += v, cx[i] += v * first;
}
long long sum(int first) {
  long long res = 0;
  for (int i = first; ~i; (i &= (i + 1))--) res += c[i] * first - cx[i];
  return res;
}
void add(int first, int second, long long v) {
  if (first >= second) return;
  add(first - 1, v), add(second - 1, -v);
}
long long sum(int first, int second) {
  if (first >= second) return 0;
  return sum(second - 1) - sum(first - 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m >> a >> b >> t, nt = t;
  reverse(b.begin(), b.end()), reverse(nt.begin(), nt.end());
  zfun(t + a, za), zfun(nt + b, zb), fa = za + m, fb = zb + m;
  reverse(b.begin(), b.end()), reverse(fb, fb + n);
  for (int i = (0), I = (n); i < I; i++)
    fa[i] = min(fa[i], m - 1), fb[i] = min(fb[i], m - 1);
  int now = m - 1;
  long long ans = 0;
  for (int i = (0), I = (now); i < I; i++)
    if (i < n) add(1, fb[i] + 1, 1);
  for (int i = (0), I = (n); i < I; i++) {
    ans += sum(max(m - fa[i], 1), m + 1);
    add(1, fb[i] + 1, -1);
    if (now < n) add(1, fb[now] + 1, 1);
    now++;
  }
  cout << ans << '\n';
  return 0;
}
