#include <bits/stdc++.h>
using namespace std;
int haystack[2 * 100010];
int needle[2 * 100010];
int P[2 * 100010];
int sol = 0;
int n, m;
inline void KMP() {
  for (int i = 0; i < m; i++) P[i] = -1;
  for (int i = 0, j = -1; i < m;) {
    while (j > -1 && needle[i] != needle[j]) j = P[j];
    i++;
    j++;
    P[i] = j;
  }
  for (int i = 0, j = 0; i < n;) {
    while (j > -1 && haystack[i] != needle[j]) j = P[j];
    i++;
    j++;
    if (j == m) {
      sol++;
      j = P[j];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  if (m == 1) {
    printf("%d\n", n);
    return 0;
  }
  int tmp;
  scanf("%d", &tmp);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    haystack[i - 1] = x - tmp;
    tmp = x;
  }
  n--;
  scanf("%d", &tmp);
  for (int i = 1; i < m; i++) {
    int x;
    scanf("%d", &x);
    needle[i - 1] = x - tmp;
    tmp = x;
  }
  m--;
  KMP();
  printf("%d\n", sol);
  return 0;
}
