#include <bits/stdc++.h>
using namespace std;
void scan(int &number) {
  bool negative = false;
  int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
int main() {
  int n, w;
  cin >> n >> w;
  if (w == 1) {
    cout << n << '\n';
    return 0;
  }
  vector<int> bear(n - 1);
  getchar();
  int pre, cur;
  scan(pre);
  for (int i = 0; i != n - 1; ++i) {
    scan(cur);
    bear[i] = cur - pre;
    pre = cur;
  }
  vector<int> elef(w - 1);
  scan(pre);
  for (int i = 0; i != w - 1; ++i) {
    scan(cur);
    elef[i] = cur - pre;
    pre = cur;
  }
  elef.push_back(INT32_MAX);
  vector<int> pi(elef.size());
  pi[0] = 0;
  for (int i = 1; i != elef.size(); ++i) {
    int j = pi[i - 1];
    while (j > 0 && elef[i] != elef[j]) j = pi[j - 1];
    if (elef[i] == elef[j]) ++j;
    pi[i] = j;
  }
  int state = 0;
  int amount = 0;
  for (int i = 0; i != bear.size(); ++i) {
    while (state > 0 && bear[i] != elef[state]) state = pi[state - 1];
    if (bear[i] == elef[state]) ++state;
    if (state == w - 1) ++amount;
  }
  cout << amount << '\n';
  return 0;
}
