#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 69, MOD = 1e9 + 7, BASE = 137;
long long n, w, Min, calc, ans, temp[MAXN], arr[MAXN], brr[MAXN], mul[MAXN],
    hsh[MAXN];
long long get(long long l, long long r) {
  if (l == 0) return hsh[r];
  return (hsh[r] - hsh[l - 1] + MOD) % MOD;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w;
  for (long long i = 0; i < n; i++) cin >> temp[i];
  for (long long i = 0; i < n - 1; i++)
    arr[i] = temp[i + 1] - temp[i], Min = min(Min, arr[i]);
  for (long long i = 0; i < w; i++) cin >> temp[i];
  for (long long i = 0; i < w - 1; i++)
    brr[i] = temp[i + 1] - temp[i], Min = min(Min, brr[i]);
  n--, w--;
  for (long long i = 0; i < n; i++) arr[i] -= Min, arr[i]++;
  for (long long i = 0; i < w; i++) brr[i] -= Min, brr[i]++;
  mul[0] = 1;
  for (long long i = 1; i < MAXN; i++) mul[i] = (mul[i - 1] * BASE) % MOD;
  hsh[0] = arr[0];
  for (long long i = 1; i < n; i++)
    hsh[i] = hsh[i - 1] + (arr[i] * mul[i]) % MOD, hsh[i] %= MOD;
  for (long long i = 0; i < w; i++)
    calc += (brr[i] * mul[i]) % MOD, calc %= MOD;
  for (long long i = w - 1; i < n; i++)
    if (get(i - w + 1, i) == (calc * mul[i - w + 1]) % MOD) ans++;
  cout << ans << "\n";
}
