#include <bits/stdc++.h>
using namespace std;
long long zFsolve(string s, long long k) {
  long long i, n = s.size();
  vector<long long> z(n);
  long long x = 0, y = 0;
  long long cnt = 0;
  for (i = 1; i < n; i++) {
    z[i] = max(0LL, min(y - i + 1, z[i - x]));
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
      x = i;
      y = i + z[i];
      z[i]++;
    }
    if (z[i] == k) cnt++;
  }
  return cnt;
}
int32_t main() {
  long long n, w, i, j, k;
  cin >> n >> w;
  string bear = "", ele = "";
  cin >> j;
  for (i = 0; i < n - 1; i++) {
    cin >> k;
    bear += to_string(k - j);
    bear += " ";
    j = k;
  }
  cin >> j;
  for (i = 0; i < w - 1; i++) {
    cin >> k;
    ele += to_string(k - j);
    ele += " ";
    j = k;
  }
  if (w == 1) {
    cout << n << endl;
    return 0;
  }
  if (w > n) {
    cout << 0;
    return 0;
  }
  long long ans = zFsolve(ele + "#" + bear, ele.size());
  cout << ans;
  return 0;
}
