#include <bits/stdc++.h>
using namespace std;
const double EPS = 0.000001;
const long long oo = 1e18;
const int INF = 1e9;
const long long mod = 1e9 + 6;
const long long base = 37;
int n, w, pf[400005], a[200005], b[200005], ans;
vector<int> v;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w;
  if (w == 1) {
    cout << n;
    return 0;
  }
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < w; ++i) cin >> b[i];
  for (int i = 0; i < w - 1; ++i) v.push_back(b[i] - b[i + 1]);
  v.push_back(INF);
  for (int i = 0; i < n - 1; ++i) v.push_back(a[i] - a[i + 1]);
  for (int i = 1; i < v.size(); ++i) {
    int j = pf[i - 1];
    while (j > 0 && v[j] != v[i]) j = pf[j - 1];
    if (v[i] == v[j]) ++j;
    pf[i] = j;
    if (pf[i] == w - 1) ++ans;
  }
  cout << ans;
  return 0;
}
