#include <bits/stdc++.h>
using namespace std;
vector<int> t, p;
int pi[200001], cnt;
void prefix_function() {
  int j = 0;
  for (int i = 1; i < p.size() - 1; i++) {
    while (j && p[i] != p[j]) j = pi[j - 1];
    if (p[i] == p[j]) j++;
    pi[i] = j;
  }
}
void kmp() {
  int j = 0;
  for (int i = 0; i < t.size() - 1; i++) {
    while (j && t[i] != p[j]) j = pi[j - 1];
    if (t[i] == p[j]) j++;
    if (j == p.size() - 1) cnt++;
  }
}
int main() {
  int n, w, r = 0;
  cin >> n >> w;
  int a[n], b[w];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < w; i++) cin >> b[i];
  for (int i = 1; i < n; i++) t.push_back(a[i] - a[i - 1]);
  for (int i = 1; i < w; i++) p.push_back(b[i] - b[i - 1]);
  t.push_back(1000000010), p.push_back(1000000010);
  if (w == 1)
    cout << n;
  else {
    prefix_function();
    kmp();
    cout << cnt;
  }
}
