#include <bits/stdc++.h>
using namespace std;
inline int getc() {
  static const int L = 1 << 15;
  static char buf[L], *S = buf, *T = buf;
  if (S == T) {
    T = (S = buf) + fread(buf, 1, L, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
inline int getint() {
  int c;
  while (!isdigit(c = getc()))
    ;
  int tmp = c - '0';
  while (isdigit(c = getc())) tmp = (tmp << 1) + (tmp << 3) + c - '0';
  return tmp;
}
int fix, a[201000], pre[201000], n, m, s[201000], ans;
int main() {
  int i, j, k, x, y;
  n = getint(), m = getint();
  if (m == 1) {
    printf("%d\n", n);
    return 0;
  }
  if (n < m) {
    printf("0");
    return 0;
  }
  x = getint();
  for (i = 1; i < n; i++) {
    y = getint();
    a[i] = y - x;
    x = y;
  }
  n--;
  x = getint();
  for (i = 1; i < m; i++) {
    y = getint();
    s[i] = y - x;
    x = y;
  }
  m--;
  for (fix = 0, i = 2; i <= m; i++) {
    while (fix && s[fix + 1] != s[i]) fix = pre[fix];
    if (s[fix + 1] == s[i]) fix++;
    pre[i] = fix;
  }
  for (fix = 0, i = 1; i <= n; i++) {
    while (fix && s[fix + 1] != a[i]) fix = pre[fix];
    if (s[fix + 1] == a[i]) fix++;
    if (fix == m) ans++, fix = pre[fix];
  }
  printf("%d\n", ans);
  return 0;
}
