#include <bits/stdc++.h>
using namespace std;
vector<int> build_z(const vector<int>& a) {
  int n = (int)(a).size();
  vector<int> z(n);
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    z[i] = max(0, min(z[i - l], r - i));
    while (i + z[i] < n && a[z[i]] == a[z[i] + i]) z[i]++;
    if (i + z[i] > r) l = i, r = i + z[i];
  }
  return z;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(m); i++) cin >> b[i];
  auto get_diff = [&](vector<int> a) {
    vector<int> ret;
    for (int i = 1; i < (int)(a).size(); i++) ret.push_back(a[i] - a[i - 1]);
    return ret;
  };
  auto da = get_diff(a), db = get_diff(b);
  vector<int> com = db;
  com.push_back(1e9 + 7);
  for (int i : da) com.push_back(i);
  auto z = build_z(com);
  int cnt = 0;
  for (int i = m - 1; i < (int)(z).size(); i++) cnt += (z[i] == m - 1);
  cout << cnt << "\n";
}
