#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int popcount(T t) {
  if (std::numeric_limits<T>::digits <=
      std::numeric_limits<unsigned int>::digits) {
    return __builtin_popcount(t);
  } else {
    return __builtin_popcountll(t);
  }
}
const long double EPS = 1e-8;
const long double PI = acosl(0.0) * 2;
int numOcc(vector<int> a, vector<int> b) {
  int m = a.size();
  a.push_back(1000000007);
  for (int i = 0; i < int((b).size()); ++i) a.push_back(b[i]);
  vector<int> p(a.size());
  for (int i = 1; i <= int(p.size() - 1); ++i) {
    int k = p[i - 1];
    while (k > 0 && a[k] != a[i]) k = p[k - 1];
    p[i] = k + int(a[k] == a[i]);
  }
  int ret = 0;
  for (int i = 0; i < int((p).size()); ++i)
    if (p[i] == m) ++ret;
  return ret;
}
void solve() {
  int n, m;
  cin >> m >> n;
  if (n == 1) {
    cout << m << endl;
    return;
  }
  vector<int> a(n), b(m);
  for (int i = 0; i < int(m); ++i) cin >> b[i];
  for (int i = 0; i < int(n); ++i) cin >> a[i];
  for (int i = 0; i < int(n - 1); ++i) a[i] -= a[i + 1];
  a.resize(n - 1);
  for (int i = 0; i < int(m - 1); ++i) b[i] -= b[i + 1];
  b.resize(m - 1);
  cout << numOcc(a, b) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
