#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
int x[maxn], y[maxn];
int nxt[maxn];
void kmp_pre(int x[], int m, int next[]) {
  int i, j;
  j = next[0] = -1;
  i = 0;
  while (i < m) {
    while (-1 != j && x[i] != x[j]) j = next[j];
    next[++i] = ++j;
  }
}
int KMP_Count(int x[], int m, int y[], int n) {
  int i, j;
  int ans = 0;
  kmp_pre(x, m, nxt);
  i = j = 0;
  while (i < n) {
    while (-1 != j && y[i] != x[j]) j = nxt[j];
    i++;
    j++;
    if (j >= m) {
      ans++;
      j = nxt[j];
    }
  }
  return ans;
}
int main(void) {
  int n, w;
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) {
    scanf("%d", &y[i]);
    if (i >= 1) y[i - 1] = y[i] - y[i - 1];
  }
  for (int i = 0; i < w; i++) {
    scanf("%d", &x[i]);
    if (i >= 1) x[i - 1] = x[i] - x[i - 1];
  }
  if (w == 1)
    printf("%d\n", n);
  else
    printf("%d\n", KMP_Count(x, w - 1, y, n - 1));
  return 0;
}
