#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 5e5 + 7;
long long n, m;
string a, b, s;
long long prf[maxn], suf[maxn];
long long l, r, z[maxn];
struct BinaryIndexedTree {
  long long BIT[maxn];
  void Update(long long pos, long long val) {
    for (; pos < maxn; pos += pos & -pos) BIT[pos] += val;
  }
  long long Query(long long pos) {
    long long ans = 0;
    for (; pos > 0; pos -= pos & -pos) ans += BIT[pos];
    return ans;
  }
} Tree[2];
void zfunction(string s) {
  l = r = -1;
  for (long long i = 1; i < s.length(); i++) {
    if (r < i) {
      l = r = i;
      while (r < s.length() && s[r] == s[r - l]) {
        r++;
      }
      z[i] = (r - l);
      r--;
    } else {
      long long k = (i - l);
      if (z[k] < r - i + 1)
        z[i] = z[k];
      else {
        l = i;
        while (r < s.length() && s[r] == s[r - l]) r++;
        z[i] = (r - l);
        r--;
      }
    }
  }
}
void prepare() {
  string z1 = s + '#' + a;
  l = r = -1;
  zfunction(z1);
  for (long long i = m + 1; i < z1.length(); i++) {
    prf[i - m - 1] = z[i];
  }
  reverse(b.begin(), b.end());
  reverse(s.begin(), s.end());
  z1 = s + '#' + b;
  zfunction(z1);
  for (long long i = m + 1; i < z1.length(); i++) {
    suf[n - (i - m - 1) - 1] = z[i];
  }
}
vector<long long> vt(0);
long long Find(long long x) {
  long long it = lower_bound(vt.begin(), vt.end(), x) - vt.begin();
  if (it < vt.size()) return it + 1;
  return vt.size() + 1;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
  cin >> n >> m >> a >> b >> s;
  prepare();
  for (long long i = 0; i < n; i++) {
    if (suf[i] == m) suf[i]--;
    if (prf[i] == m) prf[i]--;
    vt.push_back(suf[i] - m + 1);
  }
  sort(vt.begin(), vt.end());
  vt.erase(unique(vt.begin(), vt.end()), vt.end());
  long long cur = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    if (i > 0 && suf[i - 1]) {
      long long x = Find(suf[i - 1] - m + 1);
      Tree[0].Update(x, -1);
      Tree[1].Update(x, -(suf[i - 1] - m + 1));
    }
    long long limit = i + m - 2;
    while (cur <= limit) {
      long long x = Find(suf[cur] - m + 1);
      if (suf[cur]) {
        Tree[0].Update(x, 1);
        Tree[1].Update(x, suf[cur] - m + 1);
      }
      cur += 1;
    }
    long long low = Find(-prf[i]);
    if (prf[i]) {
      long long cnt = Tree[0].Query(maxn - 1) - Tree[0].Query(low - 1);
      long long val = Tree[1].Query(maxn - 1) - Tree[1].Query(low - 1);
      ans += prf[i] * cnt + val;
    }
  }
  cout << ans;
}
