#include <bits/stdc++.h>
using namespace std;
long long rd() {
  long long x = 0, f = 1;
  char c = getchar();
  while (not isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return x * f;
}
const int N = 2e5 + 5;
int n = rd(), m = rd();
int a[N], b[N], nxt[N];
void get_nxt() {
  int j = 0, k = nxt[0] = -1;
  while (j < m) k == -1 or b[j] == b[k] ? nxt[++j] = ++k : k = nxt[k];
}
int count_num() {
  int ret = 0;
  int i = 0, j = 0;
  while (i < n) {
    j == -1 or a[i] == b[j] ? ++i, ++j : j = nxt[j];
    if (j == m) ret++, j = nxt[j];
  }
  return ret;
}
int main() {
  if (m == 1) printf("%d\n", n), exit(0);
  for (int i = 0; i < n; i++) a[i] = rd();
  for (int i = 0; i < m; i++) b[i] = rd();
  n--, m--;
  for (int i = 0; i < n; i++) a[i] = a[i] - a[i + 1];
  for (int i = 0; i < m; i++) b[i] = b[i] - b[i + 1];
  get_nxt();
  printf("%d\n", count_num());
}
