#include <bits/stdc++.h>
using namespace std;
vector<long long> buildFail(vector<long long> p) {
  long long m = p.size();
  vector<long long> fail(m + 100);
  long long j = fail[0] = -1;
  for (long long i = 1; i <= m; ++i) {
    while (m >= j && j >= 0 && p[j] != p[i - 1]) j = fail[j];
    fail[i] = ++j;
  }
  return fail;
}
long long match(vector<long long> t, vector<long long> p,
                vector<long long> fail) {
  long long n = t.size(), m = p.size();
  long long count = 0;
  for (long long i = 0, k = 0; i < n; ++i) {
    while (m > k && k >= 0 && p[k] != t[i]) k = fail[k];
    if (++k >= m) {
      ++count;
      k = fail[k];
    }
  }
  return count;
}
int main() {
  long long i, j, k;
  long long n, m;
  cin >> n >> m;
  if (n < m) {
    cout << 0 << endl;
    return 0;
  }
  vector<long long> a(n + 100), b(m + 100), ad(n - 1), bd(m - 1);
  long long hashb = 0, r = 173205080, hasha = 0, MOD = 1e9 + 7;
  for (int(i) = 0; (i) < int(n); ++(i)) cin >> a[i];
  for (int(i) = 0; (i) < int(n - 1); ++(i)) ad[i] = a[i + 1] - a[i] + 1e9;
  for (int(i) = 0; (i) < int(m); ++(i)) cin >> b[i];
  for (int(i) = 0; (i) < int(m - 1); ++(i)) {
    bd[i] = b[i + 1] - b[i] + 1e9;
    hashb *= r;
    hashb = (hashb % MOD + MOD) % MOD;
    hashb += bd[i];
    hashb = (hashb % MOD + MOD) % MOD;
  }
  long long rr = 1;
  for (int(i) = 0; (i) < int(m - 1); ++(i)) {
    rr *= r;
    rr %= MOD;
    hasha *= r;
    hasha = (hasha % MOD + MOD) % MOD;
    hasha += ad[i];
    hasha = (hasha % MOD + MOD) % MOD;
  }
  long long re = 0;
  for (i = m - 1; i < n; i++) {
    if (hasha == hashb) re++;
    if (i == n - 1) break;
    hasha *= r;
    hasha = (hasha % MOD + MOD) % MOD;
    hasha -= ad[i - m + 1] * rr;
    hasha += ad[i];
    hasha = (hasha % MOD + MOD) % MOD;
  }
  cout << re << endl;
  return 0;
}
