#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, m, T, w;
int ans;
int read() {
  int x = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
int a[N], b[N];
int nex[N];
bool flag;
void Getprefix(int l) {
  nex[0] = -1;
  int i = -1, j = 0;
  while (j < l) {
    if (i == -1 || b[i] == b[j]) {
      ++j;
      ++i;
      nex[j] = i;
    } else
      i = nex[i];
  }
  return;
}
void KMP(int ld, int ls) {
  int i = 0, j = 0;
  while (i < ld) {
    if (j == -1 || a[i] == b[j]) {
      i++, j++;
      if (j == ls) ans++, j = nex[j];
    } else
      j = nex[j];
  }
}
int main() {
  n = read();
  w = read();
  for (int i = 0; i < n; i++) a[i] = read();
  for (int i = 0; i < w; i++) b[i] = read();
  for (int i = 0; i < n - 1; i++) a[i] = a[i + 1] - a[i];
  for (int i = 0; i < w - 1; i++) b[i] = b[i + 1] - b[i];
  Getprefix(w - 1);
  KMP(n - 1, w - 1);
  if (w == 1) ans += 1;
  cout << ans << endl;
  return 0;
}
