#include <bits/stdc++.h>
using namespace std;
long Min(long i, long j) { return i < j ? i : j; }
long Max(long i, long j) { return i > j ? i : j; }
long n, w;
long a[1000005];
long b[1000005];
long pi[1000005];
long x[1000005], y[1000005];
void cpf() {
  int i, j, k;
  pi[1] = 0;
  k = 0;
  for (i = 2; i < w; i++) {
    while (k && x[k + 1] != x[i]) k = pi[k];
    if (x[k + 1] == x[i]) k++;
    pi[i] = k;
  }
}
int kmp() {
  int ret = 0;
  int i, j, k = 0;
  for (i = 1; i < n; i++) {
    while (k && y[i] != x[k + 1]) k = pi[k];
    if (y[i] == x[k + 1]) k++;
    if (k == w - 1) {
      ret++;
      k = pi[k];
    }
  }
  return ret;
}
int main() {
  long i, j, k;
  while (cin >> n >> w) {
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = 1; i <= w; i++) cin >> b[i];
    if (w == 1) {
      cout << n << endl;
      continue;
    }
    for (i = 2; i <= n; i++) y[i - 1] = a[i] - a[i - 1];
    for (i = 2; i <= w; i++) x[i - 1] = b[i] - b[i - 1];
    cpf();
    cout << kmp();
  }
  return 0;
}
