#include <bits/stdc++.h>
using namespace std;
int N, W, Ts;
int B[200001];
int E[200001];
long long int T[400001];
int Z[400001];
long long int Dollar = 1e10;
int cnt;
void CZ() {
  int l, r;
  l = 0;
  r = 0;
  for (int i = 1; i < Ts; i++) {
    if (i > r) {
      l = r = i;
      while (r < Ts && T[r] == T[r - l]) r++;
      Z[i] = r - l;
      r--;
    } else {
      int ind = i - l;
      if (i + Z[ind] <= r) {
        Z[i] = Z[ind];
      } else {
        l = i;
        while (r < Ts && T[r] == T[r - l]) r++;
        Z[i] = r - l;
        r--;
      }
    }
  }
}
int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < W; i++) {
    cin >> E[i];
  }
  Ts = 0;
  for (int i = 1; i < W; i++) {
    T[Ts++] = E[i] - E[i - 1];
  }
  T[Ts++] = Dollar;
  for (int i = 1; i < N; i++) {
    T[Ts++] = B[i] - B[i - 1];
  }
  CZ();
  for (int i = 0; i < Ts; i++) {
    if (Z[i] == W - 1) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
