#include <bits/stdc++.h>
using namespace std;
int T[200200], P[200200];
int b[200200], n, m;
void kmpPreprocess() {
  int i = 0, j = -1;
  b[0] = -1;
  while (i < m) {
    while (j >= 0 && P[i] != P[j]) j = b[j];
    i++;
    j++;
    b[i] = j;
  }
}
int cnt;
void kmpSearch() {
  int i = 0, j = 0;
  while (i < n) {
    while (j >= 0 && T[i] != P[j]) j = b[j];
    i++;
    j++;
    if (j == m) {
      cnt++;
      j = b[j];
    }
  }
}
int main() {
  int l, a;
  scanf("%d%d", &n, &m);
  scanf("%d", &l);
  n--;
  m--;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    T[i] = a - l;
    l = a;
  }
  scanf("%d", &l);
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    P[i] = a - l;
    l = a;
  }
  if (m == 0) {
    printf("%d\n", n + 1);
    return 0;
  }
  kmpPreprocess();
  kmpSearch();
  printf("%d\n", cnt);
}
