#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> A(n), B(m);
  n--, m--;
  int pre, x;
  cin >> pre;
  for (int i = 0; i < n; i++) {
    cin >> x;
    A[i] = x - pre;
    pre = x;
  }
  cin >> pre;
  for (int i = 0; i < m; i++) {
    cin >> x;
    B[i] = x - pre;
    pre = x;
  }
  if (m == 0) {
    cout << n + 1 << '\n';
    return 0;
  }
  vector<int> pi(m);
  for (int i = 1; i < m; i++) {
    int j = pi[i - 1];
    while (j > 0 && B[i] != B[j]) {
      j = pi[j - 1];
    }
    if (B[i] == B[j]) {
      j++;
    }
    pi[i] = j;
  }
  int ans = 0;
  for (int i = 0, j = 0; i < n; i++) {
    while (j > 0 && B[j] != A[i]) {
      j = pi[j - 1];
    }
    if (B[j] == A[i]) {
      j++;
    }
    if (j == m) {
      j = pi[j - 1];
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
