#include <bits/stdc++.h>
const int MAXN = 5e5 + 10;
const double eps = 1e-8;
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
using namespace std;
struct edge {
  int t, v;
  edge *next;
} e[MAXN << 1], *h[MAXN], *o = e;
void add(int x, int y, int vul) {
  o->t = y;
  o->v = vul;
  o->next = h[x];
  h[x] = o++;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int n, m;
char s1[MAXN], s2[MAXN << 1], s3[MAXN];
long long pow1[MAXN], pow2[MAXN];
int sum1[2][MAXN], sum2[2][MAXN << 1];
void csh() {
  pow1[0] = pow2[0] = 1;
  int sz = min(n, m);
  for (int i = 1; i <= sz; i++) {
    pow1[i] = 1ll * pow1[i - 1] * 131 % mod1;
    pow2[i] = 1ll * pow2[i - 1] * 233 % mod2;
  }
}
typedef struct Hash {
  int p[MAXN];
  void csh() {
    for (int i = 1; i <= n; i++) {
      sum1[0][i] = (1ll * sum1[0][i - 1] * 131 % mod1 + s1[i] - 'a') % mod1;
      sum2[0][i] = (1ll * sum2[0][i - 1] * 233 % mod2 + s1[i] - 'a') % mod2;
    }
    for (int i = 1; i <= m; i++) {
      sum1[1][i] = (1ll * sum1[1][i - 1] * 131 % mod1 + s2[i] - 'a') % mod1;
      sum2[1][i] = (1ll * sum2[1][i - 1] * 233 % mod2 + s2[i] - 'a') % mod2;
    }
  }
  bool check(int x, int y) {
    int t1 =
        (sum1[0][x + y - 1] - sum1[0][x - 1] * pow1[y] % mod1 + mod1) % mod1;
    int t2 = sum1[1][y];
    if (t1 != t2) return 0;
    t1 = (sum2[0][x + y - 1] - sum2[0][x - 1] * pow2[y] % mod2 + mod2) % mod2;
    t2 = sum2[1][y];
    if (t1 != t2) return 0;
    return 1;
  }
  void solve() {
    for (int i = 1; i <= n; i++) {
      int l = 1;
      int r = min(m, n - i + 1);
      int ans = 0;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(i, mid))
          ans = mid, l = mid + 1;
        else
          r = mid - 1;
      }
      p[i] = ans;
    }
  }
} Hash;
Hash T1, T2;
long long sum[MAXN << 1];
int num[MAXN << 1];
int get_id(int x) { return x & (-x); }
void update(int x, int y) {
  for (int i = x; i <= m; i += get_id(i)) sum[i] += y;
}
void update1(int x, int y) {
  for (int i = x; i <= m; i += get_id(i)) num[i] += y;
}
long long Sum(int x) {
  long long ans = 0;
  for (int i = x; i > 0; i -= get_id(i)) ans += sum[i];
  return ans;
}
int Sum1(int x) {
  int cnt = 0;
  for (int i = x; i > 0; i -= get_id(i)) cnt += num[i];
  return cnt;
}
int main() {
  n = read();
  m = read();
  csh();
  scanf("%s", s1 + 1);
  scanf("%s", s3 + 1);
  scanf("%s", s2 + 1);
  T1.csh();
  T1.solve();
  for (int i = 1; i <= n; i++) swap(s1[i], s3[i]);
  reverse(s1 + 1, s1 + n + 1);
  reverse(s2 + 1, s2 + m + 1);
  T2.csh();
  T2.solve();
  reverse(T2.p + 1, T2.p + n + 1);
  int r = min(n, m - 1);
  int pp = 0;
  for (int i = 1; i <= r; i++) {
    int x = T2.p[i];
    if (!x) continue;
    x = m - x;
    if (x)
      update1(x, 1), update(x, x);
    else
      pp++;
  }
  cout << endl;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int y = min(m - 1, T1.p[i]);
    ans += 1ll * (y + 1) * Sum1(y) - Sum(y) + 1ll * pp * y;
    int x = T2.p[i];
    if (x) {
      x = m - x;
      if (!x)
        pp--;
      else
        update1(x, -1), update(x, -x);
    }
    r++;
    if (r > n)
      continue;
    else {
      x = T2.p[r];
      if (x) {
        x = m - x;
        if (!x)
          pp++;
        else
          update1(x, 1), update(x, x);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
