#include <bits/stdc++.h>
const int M = 2e5 + 5;
int Next[M], a[M], b[M], w, n;
void getnext() {
  int i = 0, k = -1;
  Next[0] = -1;
  while (i < w - 1) {
    if (k == -1 || b[i] == b[k]) {
      i++;
      k++;
      Next[i] = k;
    } else {
      k = Next[k];
    }
  }
}
int main() {
  scanf("%d%d", &n, &w);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; i++) a[i] = a[i] - a[i + 1];
  for (int i = 0; i < w; i++) scanf("%d", &b[i]);
  for (int i = 0; i < w - 1; i++) b[i] = b[i] - b[i + 1];
  getnext();
  int i = 0, j = 0;
  int ans = 0;
  if (w == 1) {
    printf("%d\n", n);
    return 0;
  }
  n--, w--;
  while (i < n) {
    if (j == -1 || b[j] == a[i]) {
      i++;
      j++;
    } else {
      j = Next[j];
    }
    if (j == w) {
      ans++;
      j = Next[j];
    }
  }
  printf("%d\n", ans);
  return 0;
}
