#include <bits/stdc++.h>
using namespace std;
int n, w, i, a, b, c, len, f[int(2e5 + 5)];
vector<int> v1, v2;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w;
  for (; i < n; ++i) {
    b = a, cin >> a;
    if (i) v1.push_back(a - b);
  }
  for (i = 0; i < w; ++i) {
    b = a, cin >> a;
    if (i) v2.push_back(a - b);
  }
  if (w > n) return cout << 0, 0;
  if (w == 1) return cout << n, 0;
  for (i = 1; i < v2.size(); ++i) {
    while (len && v2[i] != v2[len]) len = f[len - 1];
    len += (v2[i] == v2[len]);
    f[i] = len;
  }
  len = 0;
  for (i = 0; i < v1.size(); ++i) {
    while (len && v1[i] != v2[len]) len = f[len - 1];
    len += (v1[i] == v2[len]);
    if (len == v2.size()) c++, len = f[len - 1];
  }
  cout << c;
  return 0;
}
