#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5, inf = 2e9 + 5;
int A[N], PRV[N], n, w, rt, x;
int main() {
  scanf("%d %d", &n, &w);
  A[w] = inf;
  for (int i = n + w; ~i; i--) scanf("%d", &A[i -= (i == w)]);
  if (w == 1) return !printf("%d", n);
  for (int i = 1; i <= n + w; i++) {
    while (x && (A[i] - A[i - 1]) ^ (A[x] - A[x - 1])) x = PRV[x];
    rt += ((PRV[i + 1] = ++x) == w);
  }
  printf("%d", rt);
}
