#include <bits/stdc++.h>
using namespace std;
const int MAXM = 400005;
int ss[MAXM];
int zz[MAXM];
int main() {
  ios_base::sync_with_stdio(false);
  int n, w;
  cin >> n >> w;
  if (w == 1) {
    cout << n << endl;
    return 0;
  }
  n--;
  w--;
  int a;
  int b;
  cin >> a;
  for (int i = 0; i < n; i++) {
    cin >> b;
    ss[w + 1 + i] = b - a;
    a = b;
  }
  cin >> a;
  for (int i = 0; i < w; i++) {
    cin >> b;
    ss[i] = b - a;
    a = b;
  }
  ss[w] = 1e9 + 1e3;
  int nn = n + w + 1;
  for (int i = 1; i < nn; i++) {
    int j = zz[i - 1];
    while (j > 0 && ss[i] != ss[j]) {
      j = zz[j - 1];
    }
    if (ss[i] == ss[j]) {
      j++;
    }
    zz[i] = j;
  }
  int ans = 0;
  for (int i = w; i < nn; i++) {
    if (zz[i] == w) {
      ans++;
    }
  }
  cout << ans << endl;
}
