#include <bits/stdc++.h>
using namespace std;
int n, w, ans = 0;
vector<int> a, b, v, z;
int main() {
  cin >> n >> w;
  a.resize(n);
  b.resize(w);
  cin >> a[0];
  for (int i = 1; i < n; ++i) {
    cin >> a[i];
    a[i - 1] -= a[i];
  }
  cin >> b[0];
  for (int i = 1; i < w; ++i) {
    cin >> b[i];
    b[i - 1] -= b[i];
  }
  if (w > n) {
    cout << 0;
    return 0;
  }
  if (w == 1) {
    cout << n;
    return 0;
  }
  v = vector<int>(b.begin(), b.end() - 1);
  v.insert(v.end(), a.begin(), a.end() - 1);
  z.resize(v.size());
  for (int i = 1, r = 0, l = 0; i < v.size(); ++i) {
    if (i <= r) z[i] = min(z[i - l], r - i + 1);
    while (i + z[i] < v.size() && v[z[i]] == v[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
  --n;
  --w;
  for (int i = 0; i < n; ++i)
    if (z[i + w] >= w) ++ans;
  cout << ans;
  return 0;
}
