#include <bits/stdc++.h>
using namespace std;
const int maxn = 100500 * 2;
const long long P1 = 1000000007, P2 = 1000000013;
const long long T = 2000000009;
int n, w, a[maxn], b[maxn], sa[maxn], sb[maxn];
long long t1[maxn], t2[maxn], h1[maxn], h2[maxn];
void calcT() {
  t1[0] = t2[0] = 1LL;
  for (int i = 1; i < maxn; i++) {
    t1[i] = (t1[i - 1] * T) % P1;
    t2[i] = (t2[i - 1] * T) % P2;
  }
}
void calcH() {
  for (int i = 1; i <= n; i++) {
    h1[i] = (h1[i - 1] + a[i] * t1[i - 1]) % P1;
    h2[i] = (h2[i - 1] + a[i] * t2[i - 1]) % P2;
  }
}
pair<long long, long long> calcHH() {
  long long hh1 = 0, hh2 = 0;
  for (int i = 1; i <= w; i++) {
    hh1 = (hh1 + b[i] * t1[i - 1]) % P1;
    hh2 = (hh2 + b[i] * t2[i - 1]) % P2;
  }
  hh1 = (hh1 * t1[maxn - 2]) % P1;
  hh2 = (hh2 * t2[maxn - 2]) % P2;
  return make_pair(hh1, hh2);
}
long long getHash(int l, int r, long long* t, long long* h, long long P) {
  long long res = (h[r] - h[l - 1]) % P;
  if (res < 0) res += P;
  res = (res * t[maxn - l - 1]) % P;
  return res;
}
pair<long long, long long> getHash(int l, int r) {
  return make_pair(getHash(l, r, t1, h1, P1), getHash(l, r, t2, h2, P2));
}
int main() {
  scanf("%d%d", &n, &w);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= w; i++) scanf("%d", b + i);
  for (int i = 1; i < n; i++) {
    sa[i] = a[i] - a[i + 1] + 1000000000;
  }
  for (int i = 1; i < w; i++) {
    sb[i] = b[i] - b[i + 1] + 1000000000;
  }
  n--;
  w--;
  for (int i = 1; i <= n; i++) a[i] = sa[i];
  for (int i = 1; i <= w; i++) b[i] = sb[i];
  calcT();
  calcH();
  pair<long long, long long> mh = calcHH();
  int res = 0;
  for (int i = 1; i <= n - w + 1; i++) {
    if (getHash(i, i + w - 1) == mh) res++;
  }
  printf("%d\n", res);
  return 0;
}
