#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 7;
long long n, m, a[maxn], b[maxn];
vector<long long> za, zb;
void input() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < m; i++) cin >> b[i];
  for (long long i = 1; i < n; i++) za.push_back(a[i] - a[i - 1]);
  for (long long i = 1; i < m; i++) zb.push_back(b[i] - b[i - 1]);
}
vector<long long> ZFUNC(vector<long long> &s) {
  long long ss = s.size();
  vector<long long> z(ss);
  for (long long i = 1, l = 0, r = 0; i < ss; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (z[i] + i < ss && s[z[i]] == s[i + z[i]]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
long long NOA() {
  if (zb.size() == 0) return za.size() + 1;
  vector<long long> str = zb;
  str.insert(str.end(), za.begin(), za.end());
  vector<long long> z = ZFUNC(str);
  long long res = 0;
  for (long long i = zb.size(); i < z.size(); i++) {
    if (z[i] >= zb.size()) res++;
  }
  return res;
}
int32_t main() {
  input();
  cout << NOA();
}
