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