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