#include <bits/stdc++.h>
using namespace std;
void zfun(const int* s, int* z, int n) {
  for (int i = 1, l = 0, r = 0; i < n; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
      ++z[i];
    }
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
}
const int MX = 2 * 100 * 1000 + 9;
int a[MX];
int b[MX];
int da[MX];
int db[MX];
int n, w;
int concat[2 * MX];
int res[2 * MX];
const int INF = 1000 * 1000 * 1000 + 9;
int solve(void) {
  if (w > n) return 0;
  if (w == 1) return n;
  for (int i = 0; i + 1 < n; i++) da[i] = a[i + 1] - a[i];
  for (int i = 0; i + 1 < w; i++) db[i] = b[i + 1] - b[i];
  for (int i = 0; i < w - 1; i++) concat[i] = db[i];
  concat[w - 1] = INF;
  for (int i = w; i < w + n - 1; i++) concat[i] = da[i - w];
  zfun(concat, res, w + n - 1);
  int result = 0;
  for (int i = 0; i < w + n - 1; i++) result += res[i] == w - 1;
  return result;
}
int main() {
  cin >> n >> w;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < w; i++) cin >> b[i];
  cout << solve();
  return 0;
}
