#include <bits/stdc++.h>
using namespace std;
int a1[200010], a2[200010], res[200010], text[200010], pre[200010], dp[200010];
bool end[200010];
int main() {
  int n, w;
  scanf("%d%d", &n, &w);
  if (w == 1) {
    printf("%d", n);
    return 0;
  }
  if (n < w) {
    printf("0");
    return 0;
  }
  register int i, j;
  for (i = 1; i <= n; ++i) scanf("%d", &a1[i]);
  for (i = 1; i <= w; ++i) scanf("%d", &a2[i]);
  for (i = 1; i < w; ++i) res[i] = a2[i + 1] - a2[i];
  --w;
  for (i = 1; i < n; ++i) text[i] = a1[i + 1] - a1[i];
  --n;
  pre[1] = 0;
  j = 0;
  res[w + 1] = (int)1e9;
  for (i = 2; i <= w; ++i) {
    while (j && res[j + 1] != res[i]) j = pre[j];
    if (res[j + 1] == res[i]) ++j;
    pre[i] = j;
  }
  int tot = 0;
  j = 0;
  for (i = 1; i <= n; ++i) {
    while (j && res[j + 1] != text[i]) j = pre[j];
    if (res[j + 1] == text[i]) ++j;
    if (j == w) ++tot;
  }
  printf("%d\n", tot);
  return 0;
}
