#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int s[M], p[M], nxt[M];
int n, w;
void init_nxt() {
  int i = 0, j = -1;
  nxt[0] = -1;
  while (i < w) {
    if (j == -1 || p[j] == p[i]) {
      ++i, ++j;
      if (p[i] == p[j])
        nxt[i] = nxt[j];
      else
        nxt[i] = j;
    } else
      j = nxt[j];
  }
}
int KMP() {
  int i = 0, j = 0, ans = 0;
  while (i < n) {
    if (j == -1 || p[j] == s[i]) {
      ++i;
      ++j;
      if (j == w) {
        j = nxt[j];
        ++ans;
      }
    } else
      j = nxt[j];
  }
  return ans;
}
int main() {
  scanf("%d %d", &n, &w);
  if (w == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i < n; ++i) scanf("%d", s + i);
  for (int i = 0; i < w; ++i) scanf("%d", p + i);
  for (int i = 0; i < n - 1; ++i) s[i] = s[i + 1] - s[i];
  for (int i = 0; i < w - 1; ++i) p[i] = p[i + 1] - p[i];
  --n, --w;
  init_nxt();
  printf("%d\n", KMP());
  return 0;
}
