#include <bits/stdc++.h>
using namespace std;
int n, w, t, te, z[400010], coun, l, r;
vector<int> b, e, s;
int main() {
  cin >> n >> w;
  if (w == 1) {
    cout << n;
    return 0;
  }
  if (w > n) {
    cout << 0;
    return 0;
  }
  cin >> t;
  for (int i = 1; i < n; i++) {
    cin >> te;
    b.push_back(te - t);
    t = te;
  }
  cin >> t;
  for (int i = 1; i < w; i++) {
    cin >> te;
    e.push_back(te - t);
    t = te;
  }
  s = e;
  s.push_back(INT_MAX);
  for (int i = 0; i < b.size(); i++) {
    s.push_back(b[i]);
  }
  z[0] = s.size();
  for (int i = 1; i < s.size(); i++) {
    if (i > r) {
      l = i;
      r = i;
      while (r < s.size() && s[r] == s[r - l]) r++;
      z[i] = r - l;
      r--;
    } else if (z[i - l] < r - i + 1) {
      z[i] = z[i - l];
    } else {
      l = i;
      while (r < s.size() && s[r] == s[r - l]) r++;
      z[i] = r - l;
      r--;
    }
    if (z[i] == e.size()) {
      coun++;
    }
  }
  cout << coun;
}
