#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50, INF = 1e9 + 90, MOD = 0;
int n, w, a[N], b[N], f[2 * N], ans;
vector<int> tmp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> w;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < w; i++) cin >> b[i];
  for (int i = 1; i < w; i++) tmp.push_back(b[i] - b[i - 1]);
  tmp.push_back(INF);
  for (int i = 1; i < n; i++) tmp.push_back(a[i] - a[i - 1]);
  f[0] = -1;
  int cur = -1;
  for (int i = 1; i <= (n + w - 1); i++) {
    while (cur > -1 && tmp[cur] != tmp[i - 1]) cur = f[cur];
    cur++;
    f[i] = cur;
    if (i >= w && f[i] >= w - 1) ans++;
  }
  cout << ans << '\n';
  return 0;
}
