#include <bits/stdc++.h>
using namespace std;
struct Fenwick {
  vector<long long int> bit;
  long long int size;
  void modify(long long int j, long long int v) {
    j += 3;
    for (; j < size; j += j & -j) bit[j] += v;
  }
  long long int query(long long int j) {
    j += 3;
    long long int v = 0;
    for (; j > 0; j -= j & -j) v += bit[j];
    return v;
  }
  long long int rangequery(long long int a, long long int b) {
    return query(b) - query(a - 1);
  }
  void rangeupdate(long long int a, long long int b, long long int v) {
    modify(a, v);
    modify(b + 1, -v);
  }
  Fenwick(long long int s) {
    s += 5;
    size = s;
    bit = vector<long long int>(s, 0);
  }
};
vector<long long int> kmp(string a, string& b) {
  a.pop_back();
  string c = a + "#" + b;
  vector<long long int> K(c.length(), 0);
  long long int l = 0, r = 0;
  for (long long int i = 1; i < (long long int)(c).size(); i++) {
    if (i > r) {
      r = l = i;
      while (r < (long long int)(c).size() && c[r - l] == c[r]) {
        r++;
      }
      r--;
      K[i] = r - l + 1;
    } else {
      if (K[i - l] >= r - i + 1) {
        while (r < (long long int)(c).size() && c[r - i] == c[r]) {
          r++;
        }
        r--;
        K[i] = r - i + 1;
        l = i;
      } else
        K[i] = K[i - l];
    }
  }
  vector<long long int> temp;
  for (long long int i = (long long int)(a).size() + 1;
       i < (long long int)(c).size(); i++)
    temp.push_back(K[i]);
  return temp;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  string a, b, s;
  cin >> a >> b >> s;
  vector<long long int> pre = kmp(s, a);
  vector<long long int> suff;
  reverse((s).begin(), (s).end());
  reverse((b).begin(), (b).end());
  suff = kmp(s, b);
  reverse((suff).begin(), (suff).end());
  Fenwick sum(2e6);
  Fenwick cnt(2e6);
  long long int ans = 0;
  for (long long int i = 0; i < m - 1 && i < n; i++) {
    sum.modify(suff[i], suff[i]);
    cnt.modify(suff[i], 1);
  }
  for (long long int i = 0; i < n; i++) {
    long long int r = min(i + m - 2, n - 1);
    ans += sum.rangequery(m - pre[i] - 1, 2e6) +
           cnt.query(m - pre[i] - 2) * (m - pre[i] - 1) +
           (pre[i] - m + 1) * (r - i + 1);
    sum.modify(suff[i], -suff[i]);
    cnt.modify(suff[i], -1);
    if (r + 1 >= n) continue;
    sum.modify(suff[r + 1], suff[r + 1]);
    cnt.modify(suff[r + 1], 1);
  }
  cout << ans;
}
