#include <bits/stdc++.h>
using namespace std;
int f_t[200005];
void make_t(vector<int> w) {
  int i = 0, pos = 2;
  int n = int(w.size());
  f_t[0] = -1;
  f_t[1] = 0;
  while (pos < n) {
    if (w[pos - 1] == w[i]) {
      i++;
      f_t[pos] = i;
      pos++;
    } else if (i > 0) {
      i = f_t[i];
    } else {
      f_t[pos] = 0;
      pos++;
    }
  }
}
int kmp(vector<int> s, vector<int> w) {
  int i, j;
  int ret = 0;
  int n = int(w.size());
  int m = int(s.size());
  i = 0;
  j = 0;
  while (i + j < m) {
    if (w[j] == s[i + j]) {
      if (j == n - 1) {
        ret++;
        i = i + j - f_t[j];
        j = f_t[j];
      } else
        j++;
    } else {
      if (f_t[j] != -1) {
        i = i + j - f_t[j];
        j = f_t[j];
      } else {
        j = 0;
        i++;
      }
    }
  }
  return ret;
}
int main() {
  int n, w, i, x;
  vector<int> v, diff_a, diff_b;
  scanf("%d %d", &n, &w);
  if (w == 1) {
    printf("%d\n", n);
    return 0;
  }
  if (n < w) {
    printf("0\n");
    return 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    v.push_back(x);
  }
  for (i = 1; i < n; i++) diff_a.push_back(v[i] - v[i - 1]);
  v.clear();
  for (i = 0; i < w; i++) {
    scanf("%d", &x);
    v.push_back(x);
  }
  for (i = 1; i < w; i++) diff_b.push_back(v[i] - v[i - 1]);
  v.clear();
  make_t(diff_b);
  printf("%d\n", kmp(diff_a, diff_b));
  return 0;
}
