#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int oo = 0x3f3f3f3f;
int a[2 * N], b[N], pi[2 * N];
void solve() {
  int n, w;
  cin >> n >> w;
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= w; i++) cin >> a[i];
  if (w == 1) {
    cout << n;
    return;
  }
  if (n == 1) {
    cout << 0;
    return;
  }
  for (int i = 1; i < n; i++) b[i] = b[i] - b[i + 1];
  for (int i = 1; i < w; i++) a[i] = a[i] - a[i + 1];
  a[w] = -oo;
  for (int i = w + 1; i < w + n; i++) a[i] = b[i - w];
  int ans = 0;
  pi[1] = 0;
  for (int i = 2; i < w + n; i++) {
    int k = pi[i - 1];
    while (a[i] != a[k + 1] && k) k = pi[k];
    if (a[i] == a[k + 1]) pi[i] = k + 1;
    ans += (pi[i] == (w - 1) ? 1 : 0);
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
