#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, w;
  cin >> n >> w;
  vector<long long int> b(n), e(w);
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < w; i++) cin >> e[i];
  for (int i = n - 1; i >= 0; i--) b[i] -= b[i - 1];
  for (int i = w - 1; i >= 0; i--) e[i] -= e[i - 1];
  b.erase(b.begin());
  e.erase(e.begin());
  if (!e.size()) {
    cout << b.size() + 1;
    return 0;
  }
  vector<long long int> s = b;
  s.insert(s.begin(), 1e18);
  s.insert(s.begin(), e.begin(), e.end());
  n = s.size();
  int p[n];
  long long int cnt = 0;
  p[0] = 0;
  for (int i = 1; i < n; i++) {
    int j = p[i - 1];
    while (j > 0 && s[i] != s[j]) j = p[j - 1];
    if (s[i] == s[j]) j++;
    p[i] = j;
    if (p[i] == w - 1) cnt++;
  }
  cout << cnt;
  return 0;
}
