#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const long long int INFLL = 1e18 + 10;
const long double EPS = 1e-8;
const long double EPSLD = 1e-14;
const long long int MOD = 1000000007;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
const int MAX_N = 200010;
int n, w;
long long int a[MAX_N];
long long int b[MAX_N];
int t[MAX_N];
int q = 2;
int p = 0;
int ans = 0;
int main() {
  scanf("%d %d", &n, &w);
  if (w == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = (0); i < (int)(n); i++) scanf("%lld", &a[i]);
  for (int i = (0); i < (int)(w); i++) scanf("%lld", &b[i]);
  for (int i = (0); i < (int)(n - 1); i++) a[i] = a[i + 1] - a[i];
  for (int i = (0); i < (int)(w - 1); i++) b[i] = b[i + 1] - b[i];
  t[0] = -1;
  while (q < w - 1) {
    if (b[q - 1] == b[p]) {
      t[q] = p + 1;
      q++;
      p++;
    } else if (p > 0)
      p = t[p];
    else {
      t[q] = 0;
      q++;
    }
  }
  p = 0;
  q = 0;
  while (p + q < n - 1) {
    if (b[q] == a[p + q]) {
      if (q == w - 2) {
        ans++;
        p = p + q - t[q];
        q = t[q];
      } else
        q++;
    } else {
      p = p + q - t[q];
      if (q > 0) q = t[q];
    }
  }
  cout << ans << endl;
  return 0;
}
