#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1000000007;
const double pi = 3.1415926535897932, eps = 1e-6;
struct segtree {
  long long dat[2100000], add[2100000], n;
  void build(int nn) {
    n = 1;
    while (n <= nn) n <<= 1;
  }
  long long update(int k, int l, int r, int a, int b, long long x) {
    if (r <= a || b <= l) return dat[k] + add[k] * max(r - l, 0);
    if (a <= l && r <= b) {
      add[k] += x;
      return add[k] * (r - l) + dat[k];
    }
    dat[k] = update((k << 1) + 1, l, (l + r) >> 1, a, b, x) +
             update((k << 1) + 2, (l + r) >> 1, r, a, b, x);
    return dat[k] + add[k] * (r - l);
  }
  long long update(int l, int r, long long x) {
    if (l > r) return 0ll;
    return update(0, 0, n, l - 1, r, x);
  }
  long long query(int k, int l, int r, int a, int b) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k] + add[k] * (r - l);
    return query((k << 1) + 1, l, (l + r) >> 1, a, b) +
           query((k << 1) + 2, (l + r) >> 1, r, a, b) +
           add[k] * (min(r, b) - max(l, a));
  }
  long long query(int l, int r) {
    if (l > r) return 0ll;
    return query(0, 0, n, l - 1, r);
  }
} seg;
int n, ap[500010], bp[500010], m;
long long ans;
string a, b, t, s;
int z[1500005], l, r;
void calc() {
  int l = 0, r = 0;
  for (int i = 1; i < s.size(); i++) {
    z[i] = 0;
    if (i > r) {
      l = i, r = i;
      while (r < s.size() && s[r - l] == s[r]) r++;
      z[i] = r - l, r--;
    } else {
      int k = i - l;
      if (z[k] < r - i + 1)
        z[i] = z[k];
      else {
        l = i;
        while (r < s.size() && s[r - l] == s[r]) r++;
        z[i] = r - l, r--;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> a >> b >> t;
  s = t + '$' + a;
  calc();
  for (int(i) = (m + 1); (i) <= (n + m); (i)++) ap[i - m] = z[i];
  reverse(t.begin(), t.end()), reverse(b.begin(), b.end());
  s = t + '$' + b;
  calc();
  for (int(i) = (m + 1); (i) <= (n + m); (i)++) bp[n - (i - m) + 1] = z[i];
  reverse(t.begin(), t.end()), reverse(b.begin(), b.end());
  seg.build(m + 1);
  int p = 1;
  for (int(i) = (1); (i) <= (n); (i)++) {
    while (p <= min(n, i + m - 2)) {
      seg.update(2, min(bp[p], m - 1) + 1, 1);
      p++;
    }
    ans += seg.query(m - ap[i] + 1, m);
    seg.update(2, min(bp[i], m - 1) + 1, -1);
  }
  cout << ans << '\n';
  return 0;
}
