#include <bits/stdc++.h>
using namespace std;
vector<long long> zfun(vector<long long> s) {
  const long long N = s.size();
  vector<long long> z(N);
  z[0] = N;
  for (long long i = 1, l = 0, r = 0; i < N; ++i) {
    if (i <= r) {
      z[i] = min(r - i + 1, z[i - l]);
    }
    while ((z[i] + i < N) && (s[z[i]] == s[z[i] + i])) {
      ++z[i];
    }
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
  return z;
}
int main(void) {
  cin.tie(NULL);
  ios_base ::sync_with_stdio(false);
  long long n, w;
  cin >> n >> w;
  if (n == 1 && w == 1) {
    int t;
    for (int i = 0; i < w + n; ++i) cin >> t;
    cout << 1;
    return 0;
  } else if (n == 1) {
    int t;
    for (int i = 0; i < w + n; ++i) cin >> t;
    cout << 0;
    return 0;
  } else if (w == 1) {
    int t;
    for (int i = 0; i < w + n; ++i) cin >> t;
    cout << n;
    return 0;
  }
  vector<long long> wall(w + n - 2);
  long long t, l;
  cin >> l;
  for (int i = 0; i < n - 1; ++i) {
    cin >> t;
    wall[i + w - 1] = t - l;
    l = t;
  }
  cin >> l;
  for (int i = 0; i < w - 1; ++i) {
    cin >> t;
    wall[i] = t - l;
    l = t;
  }
  long long res = 0;
  vector<long long> z = zfun(wall);
  for (int i = w - 1; i < w + n - 2; ++i) {
    if (z[i] >= w - 1) ++res;
  }
  cout << res;
  return 0;
}
