#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
int a[MAXN];
int b[MAXN];
int txt[MAXN];
int pat[MAXN];
int table[MAXN];
void build(int n) {
  table[0] = -1;
  table[1] = 0;
  int j = 0;
  for (int i = 2; i <= n; i++) {
    while (j != -1 && pat[i - 1] != pat[j]) {
      j = table[j];
    }
    j++;
    table[i] = j;
  }
}
int match(int m, int n) {
  int j = 0;
  int res = 0;
  for (int i = 0; i < m; i++) {
    while (j != -1 && txt[i] != pat[j]) {
      j = table[j];
    }
    j++;
    if (j == n) {
      res++;
      j = table[j];
    }
  }
  return res;
}
int main() {
  int n, w;
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < w; i++) scanf("%d", &b[i]);
  if (n < w) {
    printf("0\n");
    return 0;
  }
  if (w == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i < n - 1; i++) txt[i] = a[i] - a[i + 1];
  for (int i = 0; i < w - 1; i++) pat[i] = b[i] - b[i + 1];
  build(w - 1);
  int res = match(n - 1, w - 1);
  printf("%d\n", res);
  return 0;
}
