#include <bits/stdc++.h>
using namespace std;
long long n, w;
vector<long long> a, b;
vector<long long> z_array(vector<long long> a) {
  long long n = (long long)a.size();
  vector<long long> z(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 ((i + z[i] - 1) + 1 < n &&
           a[(z[i] - 1) + 1] == a[(i + z[i] - 1) + 1]) {
      z[i]++;
    }
    if (i + z[i] - 1 > r) {
      l = i, r = i + z[i] - 1;
    }
  }
  return z;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> w;
  a.resize(n), b.resize(w);
  vector<long long> a_diff, b_diff;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) a_diff.push_back(a[i] - a[i - 1]);
  }
  for (long long i = 0; i < w; i++) {
    cin >> b[i];
    if (i != 0) b_diff.push_back(b[i] - b[i - 1]);
  }
  if (w == 1) {
    cout << n << "\n";
    return 0;
  }
  vector<long long> v;
  for (long long b_val : b_diff) {
    v.push_back(b_val);
  }
  for (long long a_val : a_diff) {
    v.push_back(a_val);
  }
  long long res = 0;
  vector<long long> Z = z_array(v);
  for (long long i = (long long)b_diff.size(); i < (long long)v.size(); i++) {
    if (Z[i] >= (long long)b_diff.size()) res++;
  }
  cout << res << "\n";
  return 0;
}
