#include <bits/stdc++.h>
using namespace std;
long long z_function(vector<long long>& s, long long pat) {
  long long n = s.size();
  vector<long long> z(n, 0);
  long long L = 0, R = 0;
  for (int i = 1; i < n; i++) {
    if (i <= R) z[i] = min(z[i - L], R - i + 1);
    while (i + z[i] < n and s[z[i]] == s[i + z[i]]) z[i]++;
    if ((i + z[i] - 1) > R) {
      L = i;
      R = i + z[i] - 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (z[i] == pat) ans++;
  }
  return ans;
}
int main() {
  long long n, w;
  cin >> n >> w;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> b(w);
  for (int i = 0; i < w; i++) cin >> b[i];
  vector<long long> total;
  for (long long i = 0; i < w - 1; i++) total.push_back(b[i] - b[i + 1]);
  total.push_back(1e9 + 7);
  for (long long i = 0; i < n - 1; i++) total.push_back(a[i] - a[i + 1]);
  cout << z_function(total, w - 1);
}
