#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int dir[8][2] = {-1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -1, 1, 1 - 1, 1, 1};
template <typename S, typename T>
inline bool Min(S &a, const T &b) {
  return a > b ? a = b, true : false;
}
template <typename S, typename T>
inline bool Max(S &a, const T &b) {
  return a < b ? a = b, true : false;
}
template <typename S, typename T>
inline void Adm(S &a, const T &b) {
  a = (a + b) % MOD;
  if (a < 0) a += MOD;
}
template <typename S, typename T>
inline void Mum(S &a, const T &b) {
  a = 1LL * a * b % MOD;
}
template <typename T>
inline bool IsPri(T x) {
  if (x < 2) return false;
  for (T i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
template <typename T>
inline T Gcd(T a, T b) {
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <typename T>
inline int BitCnt(T x) {
  int cnt = 0;
  while (x) ++cnt, x &= x - 1;
  return cnt;
}
template <typename T>
inline T MDis(T x1, T y1, T x2, T y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
template <typename T>
inline T MDis(T x1, T y1, T z1, T x2, T y2, T z2) {
  return abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2);
}
inline double EDis(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
inline double EDis(double x1, double y1, double z1, double x2, double y2,
                   double z2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
              (z1 - z2) * (z1 - z2));
}
inline long long Pow(long long a, long long n) {
  long long t = 1;
  a %= MOD;
  while (n > 0) {
    if (n & 1) t = t * a % MOD;
    a = a * a % MOD, n >>= 1;
  }
  return t % MOD;
}
inline int read() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  register int x = false;
  register char ch =
      p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
          ? EOF
          : *p1++;
  ;
  register bool sgn = false;
  while (ch != '-' && (ch < '0' || ch > '9'))
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  if (ch == '-')
    sgn = true,
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48),
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  return sgn ? -x : x;
}
const int N = 1e6 + 100;
char a[N], b[N], s[N];
int exnex[N], exten[N];
void GetNext(const char p[], int m) {
  int i = 0, j;
  exnex[0] = m;
  while (i + 1 < m && p[i] == p[i + 1]) i++;
  exnex[1] = i;
  int k = 1 + i, po = 1;
  for (i = 2; i < m; i++) {
    if (exnex[i - po] < k - i)
      exnex[i] = exnex[i - po];
    else {
      j = k - i;
      if (j < 0) j = 0;
      while (i + j < m && p[i + j] == p[j]) j++;
      exnex[i] = j;
      k = i + j, po = i;
    }
  }
}
void ExKMP(const char s[], const char p[], int n, int m) {
  GetNext(p, m);
  int i = 0, j;
  while (s[i] == p[i] && i < m && i < n) i++;
  exten[0] = i;
  int k = i, po = 0;
  for (i = 1; i < n; i++) {
    if (exnex[i - po] < k - i)
      exten[i] = exnex[i - po];
    else {
      j = k - i;
      if (j < 0) j = 0;
      while (i + j < n && j < m && s[i + j] == p[j]) j++;
      exten[i] = j;
      k = i + j, po = i;
    }
  }
}
struct BitTree {
  long long c1[N], c2[N];
  void Add(int x, long long v) {
    if (x <= 0) return;
    for (int i = x; i < N; i += ((i) & -(i))) c1[i] += v, c2[i] += v * x;
  }
  void Add(int l, int r, long long v) {
    if (l > r) return;
    Add(l, v), Add(r + 1, -v);
  }
  long long Ask(int x) {
    if (x <= 0) return 0;
    long long t = 0;
    for (int i = x; i; i -= ((i) & -(i))) t += c1[i] * (x + 1) - c2[i];
    return t;
  }
  long long Ask(int l, int r) {
    if (l > r) return 0;
    return Ask(r) - Ask(l - 1);
  }
} bit;
int A[N], B[N];
int main() {
  int n, m;
  cin >> n >> m;
  scanf("%s%s%s", a, b, s);
  ExKMP(a, s, n, m);
  memcpy(A + 1, exten, sizeof(exten[0]) * (n + 5));
  reverse(b, b + n), reverse(s, s + m);
  ExKMP(b, s, n, m);
  memcpy(B + 1, exten, sizeof(exten[0]) * (n + 5));
  reverse(B + 1, B + n + 1);
  long long ans = 0;
  int j = 0;
  for (int i = 1; i <= n; ++i) {
    while (j - i < m - 2) {
      ++j;
      Min(B[j], m - 1);
      bit.Add(1, B[j], 1);
    }
    ans += bit.Ask(m - A[i], m - 1);
    bit.Add(1, B[i], -1);
  }
  cout << ans << endl;
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

Vasya had three strings a, b and s, which consist of lowercase English letters. The lengths of strings a and b are equal to n, the length of the string s is equal to m. 

Vasya decided to choose a substring of the string a, then choose a substring of the string b and concatenate them. Formally, he chooses a segment [l_1, r_1] (1 ≤ l_1 ≤ r_1 ≤ n) and a segment [l_2, r_2] (1 ≤ l_2 ≤ r_2 ≤ n), and after concatenation he obtains a string a[l_1, r_1] + b[l_2, r_2] = a_{l_1} a_{l_1 + 1} … a_{r_1} b_{l_2} b_{l_2 + 1} … b_{r_2}.

Now, Vasya is interested in counting number of ways to choose those segments adhering to the following conditions:

  * segments [l_1, r_1] and [l_2, r_2] have non-empty intersection, i.e. there exists at least one integer x, such that l_1 ≤ x ≤ r_1 and l_2 ≤ x ≤ r_2; 
  * the string a[l_1, r_1] + b[l_2, r_2] is equal to the string s. 

Input

The first line contains integers n and m (1 ≤ n ≤ 500 000, 2 ≤ m ≤ 2 ⋅ n) — the length of strings a and b and the length of the string s.

The next three lines contain strings a, b and s, respectively. The length of the strings a and b is n, while the length of the string s is m.

All strings consist of lowercase English letters.

Output

Print one integer — the number of ways to choose a pair of segments, which satisfy Vasya's conditions.

Examples

Input

6 5
aabbaa
baaaab
aaaaa


Output

4


Input

5 4
azaza
zazaz
azaz


Output

11


Input

9 12
abcabcabc
xyzxyzxyz
abcabcayzxyz


Output

2

Note

Let's list all the pairs of segments that Vasya could choose in the first example:

  1. [2, 2] and [2, 5]; 
  2. [1, 2] and [2, 4]; 
  3. [5, 5] and [2, 5]; 
  4. [5, 6] and [3, 5]; 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int dir[8][2] = {-1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -1, 1, 1 - 1, 1, 1};
template <typename S, typename T>
inline bool Min(S &a, const T &b) {
  return a > b ? a = b, true : false;
}
template <typename S, typename T>
inline bool Max(S &a, const T &b) {
  return a < b ? a = b, true : false;
}
template <typename S, typename T>
inline void Adm(S &a, const T &b) {
  a = (a + b) % MOD;
  if (a < 0) a += MOD;
}
template <typename S, typename T>
inline void Mum(S &a, const T &b) {
  a = 1LL * a * b % MOD;
}
template <typename T>
inline bool IsPri(T x) {
  if (x < 2) return false;
  for (T i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
template <typename T>
inline T Gcd(T a, T b) {
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <typename T>
inline int BitCnt(T x) {
  int cnt = 0;
  while (x) ++cnt, x &= x - 1;
  return cnt;
}
template <typename T>
inline T MDis(T x1, T y1, T x2, T y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
template <typename T>
inline T MDis(T x1, T y1, T z1, T x2, T y2, T z2) {
  return abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2);
}
inline double EDis(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
inline double EDis(double x1, double y1, double z1, double x2, double y2,
                   double z2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
              (z1 - z2) * (z1 - z2));
}
inline long long Pow(long long a, long long n) {
  long long t = 1;
  a %= MOD;
  while (n > 0) {
    if (n & 1) t = t * a % MOD;
    a = a * a % MOD, n >>= 1;
  }
  return t % MOD;
}
inline int read() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  register int x = false;
  register char ch =
      p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
          ? EOF
          : *p1++;
  ;
  register bool sgn = false;
  while (ch != '-' && (ch < '0' || ch > '9'))
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  if (ch == '-')
    sgn = true,
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48),
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  return sgn ? -x : x;
}
const int N = 1e6 + 100;
char a[N], b[N], s[N];
int exnex[N], exten[N];
void GetNext(const char p[], int m) {
  int i = 0, j;
  exnex[0] = m;
  while (i + 1 < m && p[i] == p[i + 1]) i++;
  exnex[1] = i;
  int k = 1 + i, po = 1;
  for (i = 2; i < m; i++) {
    if (exnex[i - po] < k - i)
      exnex[i] = exnex[i - po];
    else {
      j = k - i;
      if (j < 0) j = 0;
      while (i + j < m && p[i + j] == p[j]) j++;
      exnex[i] = j;
      k = i + j, po = i;
    }
  }
}
void ExKMP(const char s[], const char p[], int n, int m) {
  GetNext(p, m);
  int i = 0, j;
  while (s[i] == p[i] && i < m && i < n) i++;
  exten[0] = i;
  int k = i, po = 0;
  for (i = 1; i < n; i++) {
    if (exnex[i - po] < k - i)
      exten[i] = exnex[i - po];
    else {
      j = k - i;
      if (j < 0) j = 0;
      while (i + j < n && j < m && s[i + j] == p[j]) j++;
      exten[i] = j;
      k = i + j, po = i;
    }
  }
}
struct BitTree {
  long long c1[N], c2[N];
  void Add(int x, long long v) {
    if (x <= 0) return;
    for (int i = x; i < N; i += ((i) & -(i))) c1[i] += v, c2[i] += v * x;
  }
  void Add(int l, int r, long long v) {
    if (l > r) return;
    Add(l, v), Add(r + 1, -v);
  }
  long long Ask(int x) {
    if (x <= 0) return 0;
    long long t = 0;
    for (int i = x; i; i -= ((i) & -(i))) t += c1[i] * (x + 1) - c2[i];
    return t;
  }
  long long Ask(int l, int r) {
    if (l > r) return 0;
    return Ask(r) - Ask(l - 1);
  }
} bit;
int A[N], B[N];
int main() {
  int n, m;
  cin >> n >> m;
  scanf("%s%s%s", a, b, s);
  ExKMP(a, s, n, m);
  memcpy(A + 1, exten, sizeof(exten[0]) * (n + 5));
  reverse(b, b + n), reverse(s, s + m);
  ExKMP(b, s, n, m);
  memcpy(B + 1, exten, sizeof(exten[0]) * (n + 5));
  reverse(B + 1, B + n + 1);
  long long ans = 0;
  int j = 0;
  for (int i = 1; i <= n; ++i) {
    while (j - i < m - 2) {
      ++j;
      Min(B[j], m - 1);
      bit.Add(1, B[j], 1);
    }
    ans += bit.Ask(m - A[i], m - 1);
    bit.Add(1, B[i], -1);
  }
  cout << ans << endl;
  return 0;
}

```