#include <bits/stdc++.h>
using namespace std;
int a[500000], b[500000], c[500000], d[500000], fail[500000], n, m, ans;
void kmp() {
  int i, j = 0;
  fail[1] = 0;
  for (i = 2; i <= m; i++) {
    while (d[i] != d[j + 1] && j > 0) j = fail[j];
    if (d[i] == d[j + 1]) j++;
    fail[i] = j;
  }
  j = 0;
  for (i = 1; i <= n; i++) {
    while (c[i] != d[j + 1] && j > 0) j = fail[j];
    if (c[i] == d[j + 1]) j++;
    if (j == m) ans++, j = fail[j];
  }
  return;
}
int main() {
  int i;
  scanf("%d%d", &n, &m);
  if (m == 1) {
    printf("%d", n);
    return 0;
  }
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) scanf("%d", &b[i]);
  for (i = 2; i <= n; i++) c[i - 1] = a[i] - a[i - 1];
  for (i = 2; i <= m; i++) d[i - 1] = b[i] - b[i - 1];
  n--;
  m--;
  kmp();
  printf("%d\n", ans);
  return 0;
}
