#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n, m;
vector<long long> a, b, v, pat;
long long cal() {
  v.clear();
  for (long long i = 1; i < m; i++) v.push_back(a[i]);
  v.push_back(1e18);
  for (long long j = 1; j < n; j++) v.push_back(b[j]);
  long long sz = v.size();
  long long ans = 0;
  pat.clear();
  pat.resize(sz, 0);
  for (long long i = 1; i < sz; i++) {
    long long j = pat[i - 1];
    while (j > 0 && v[j] != v[i]) j = pat[j - 1];
    if (v[j] == v[i]) j++;
    pat[i] = j;
    if (j == m - 1) ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  long long pre, cur;
  b.clear();
  b.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    cur = b[i];
    if (i) b[i] -= pre;
    pre = cur;
  }
  a.clear();
  a.resize(m);
  for (long long i = 0; i < m; i++) {
    cin >> a[i];
    cur = a[i];
    if (i) a[i] -= pre;
    pre = cur;
  }
  if (m == 1) {
    cout << n << "\n";
    return 0;
  }
  cout << cal() << "\n";
}
