#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  bool p = 0;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') p = 1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + (c ^ 48);
  if (p) x = -x;
}
int a[200005], b[200005];
int Hina[200005], Aya[200005], n, m, ans;
int nxt[200005];
void get_nxt() {
  nxt[0] = -1;
  int i = 0, k = -1;
  while (i < m) {
    if (k == -1 || Aya[i] == Aya[k]) {
      ++i;
      ++k;
      nxt[i] = k;
    } else {
      k = nxt[k];
    }
  }
}
void kmp() {
  int i = 0, j = 0;
  while (i < n && j < m) {
    if (j == -1 || Hina[i] == Aya[j]) {
      ++i;
      ++j;
    } else {
      j = nxt[j];
    }
    if (j >= m) {
      ++ans;
      j = nxt[j];
    }
  }
}
int main() {
  read(n), read(m);
  if (m == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  for (int i = 1; i <= m; ++i) {
    read(b[i]);
  }
  for (int i = 1; i < n; ++i) {
    Hina[i - 1] = a[i] - a[i + 1];
  }
  for (int i = 1; i < m; ++i) {
    Aya[i - 1] = b[i] - b[i + 1];
  }
  --n, --m;
  get_nxt();
  kmp();
  printf("%d\n", ans);
  return 0;
}
