#include <bits/stdc++.h>
using namespace std;
const int MaxN = int(1e5) * 2 + 256;
const int INF = int(1e9);
long long n, w, a[MaxN], b[MaxN], pi[MaxN * 3], q, res;
vector<long long> s;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (i != 1) {
      s.push_back(q - a[i]);
      q = a[i];
    } else {
      q = a[i];
    }
  }
  s.push_back(INF + 7);
  for (int i = 1; i <= w; ++i) {
    cin >> b[i];
    if (i != 1) {
      s.push_back(q - b[i]);
      q = b[i];
    } else {
      q = b[i];
    }
  }
  reverse(s.begin(), s.end());
  for (int i = 1; i < s.size(); ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  for (int i = 0; i < s.size(); ++i) {
    if (pi[i] == w - 1) {
      res++;
    }
  }
  cout << res;
  return 0;
}
