#include <bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
int Next[200005];
int n, w;
int main() {
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  memset(Next, -1, sizeof(Next));
  scanf("%d%d", &n, &w);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < w; i++) scanf("%d", &b[i]);
  for (int i = 0; i < n - 1; i++) a[i] = a[i + 1] - a[i];
  for (int i = 0; i < w - 1; i++) b[i] = b[i + 1] - b[i];
  n--;
  w--;
  int i, j;
  for (i = 1; i < w; i++) {
    j = Next[i - 1];
    while ((b[j + 1] != b[i]) && (j >= 0)) j = Next[j];
    if (b[j + 1] == b[i]) Next[i] = j + 1;
  }
  i = 0;
  j = 0;
  int ans = 0;
  while (i < n) {
    if (a[i] == b[j]) {
      i++;
      j++;
      if (j == w) {
        ans++;
      }
    } else {
      if (j == 0)
        i++;
      else
        j = Next[j - 1] + 1;
    }
  }
  if (w == 0) ans = n + 1;
  printf("%d\n", ans);
}
