#include <bits/stdc++.h>
using namespace std;
const long long N = 200 * 1000 + 100, H = 43, MOD = 333319999;
long long a[2][N], sz[5];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> sz[0] >> sz[1];
  for (int z = 0; z < 2; z++) {
    for (int i = 0; i < sz[z]; i++) cin >> a[z][i];
    for (int i = 0; i < sz[z]; i++) {
      a[z][i] -= a[z][i + 1];
      while (a[z][i] < 0) a[z][i] += MOD;
    }
    sz[z]--;
  }
  long long ans(0), tmp(1), num(0), ret(0);
  if (sz[0] < sz[1]) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < sz[1]; i++) {
    ans = (ans * H + a[1][i]) % MOD;
    tmp = (tmp * H) % MOD;
    num = (num * H + a[0][i]) % MOD;
  }
  for (int i = sz[1]; i <= sz[0]; i++) {
    if (num == ans) ret++;
    num = (num * H + a[0][i]) % MOD;
    num -= (a[0][i - sz[1]] * tmp) % MOD;
    while (num < 0) num += MOD;
  }
  cout << ret << endl;
  return 0;
}
