#include <bits/stdc++.h>
using namespace std;
vector<int> go(vector<int> T) {
  int n = T.size();
  int l = 0, r = 0;
  vector<int> Z(n);
  for (int k = 1; k < n; k++) {
    if (k > r) {
      l = r = k;
      while (r < n && T[r] == T[r - l]) r++;
      Z[k] = r - l;
      r--;
    } else {
      int k1 = k - l;
      if (Z[k1] < r - k + 1)
        Z[k] = Z[k1];
      else {
        l = k;
        while (r < n && T[r] == T[r - l]) r++;
        Z[k] = r - l;
        r--;
      }
    }
  }
  return Z;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, w;
  int cnt = 0;
  cin >> n >> w;
  vector<int> A(n), B(w);
  for (auto &it : A) cin >> it;
  for (auto &it : B) cin >> it;
  vector<int> S, P, T;
  int i;
  for (i = 0; i < n - 1; ++i) S.push_back(A[i + 1] - A[i]);
  for (i = 0; i < w - 1; ++i) P.push_back(B[i + 1] - B[i]);
  for (int e : P) T.push_back(e);
  T.push_back(10000000000);
  for (int e : S) T.push_back(e);
  vector<int> Z = go(T);
  for (int e : Z) {
    if (e == (int)P.size()) cnt++;
  }
  cout << cnt;
}
