#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const long long N = 200017;
const long long p = 2047483517;
long long prefa[2 * N];
long long prefb[2 * N];
long long pw[2 * N + 17];
void solve() {
  long long n, w;
  cin >> n >> w;
  long long a[n + 17], b[w + 17];
  pw[0] = 1;
  for (long long i = 1; i <= 2 * N - 1; i++) pw[i] = (pw[i - 1] * p) % mod;
  if (n < w) {
    cout << 0;
    return;
  }
  if (n == 1) {
    if (w == 1)
      cout << 1;
    else
      cout << 0;
    return;
  }
  if (w == 1) {
    cout << n;
    return;
  }
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= w; i++) cin >> b[i];
  long long adif[n + 17];
  long long bdif[w + 17];
  for (long long i = 2; i <= n; i++) adif[i - 1] = a[i] - a[i - 1] + 1e9 + 7;
  for (long long i = 2; i <= w; i++) bdif[i - 1] = b[i] - b[i - 1] + 1e9 + 7;
  for (long long i = 1; i <= n - 1; i++)
    prefa[i] = (prefa[i - 1] * p + (((adif[i] % mod) + mod) % mod)) % mod;
  for (long long i = 1; i <= w - 1; i++)
    prefb[i] = (prefb[i - 1] * p + ((bdif[i] % mod) + mod) % mod) % mod;
  long long ans = 0;
  for (long long i = 1; i <= n - w + 1; i++) {
    if ((((prefa[i + w - 2] - (prefa[i - 1] * pw[w - 1]) % mod) % mod) + mod) %
                mod ==
            prefb[w - 1] % mod &&
        adif[i] == bdif[1])
      ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t24 = 1;
  while (t24--) {
    solve();
    cout << "\n";
  }
}
