#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, w;
  cin >> n >> w;
  vector<int> a(n), b(w);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < w; i++) cin >> b[i];
  for (int i = 0; i < n - 1; i++) a[i] = a[i] - a[i + 1];
  for (int i = 0; i < w - 1; i++) b[i] = b[i] - b[i + 1];
  a.resize(n - 1);
  if (w == 1) {
    cout << n;
    return 0;
  }
  b.resize(w - 1);
  vector<int> c(b);
  c.push_back(INT_MAX);
  for (int i = 0; i < a.size(); i++) c.push_back(a[i]);
  int sz = int(c.size());
  vector<int> pi(sz);
  for (int i = 1; i < sz; i++) {
    int j = pi[i - 1];
    while (j > 0 && c[i] != c[j]) j = pi[j - 1];
    if (c[i] == c[j]) j++;
    pi[i] = j;
  }
  int l = int(b.size()) + 1;
  int ans = 0;
  for (int i = l; i < sz; i++) {
    if (pi[i] == int(b.size())) ans++;
  }
  cout << ans;
  return 0;
}
