#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void _read(T& x) {
  cin >> x;
}
void R() {}
template <typename T, typename... U>
void R(T& head, U&... tail) {
  _read(head);
  R(tail...);
}
template <typename T>
inline void _write(const T& x) {
  cout << x << ' ';
}
void W() { cout << endl; }
template <typename T, typename... U>
void W(const T& head, const U&... tail) {
  _write(head);
  W(tail...);
}
template <typename T>
void debug(vector<T> V) {
  for (auto x : V) {
    cout << x << " ";
  }
  cout << endl;
}
void go();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  go();
  return 0;
}
const int MAXN = 2e5 + 10;
int a[MAXN], b[MAXN], nxt[MAXN];
int kmp(int n, int w) {
  int res = 0;
  nxt[1] = 0;
  for (int i = 2, j = 0; i <= w; i++) {
    while (j != 0 && b[i] != b[j + 1]) j = nxt[j];
    if (b[i] == b[j + 1]) j++;
    nxt[i] = j;
  }
  for (int i = 1, j = 0; i <= n; i++) {
    while (j != 0 && (j == w || a[i] != b[j + 1])) j = nxt[j];
    if (a[i] == b[j + 1]) j++;
    if (j == w) res++;
  }
  return res;
}
void go() {
  int n, w;
  R(n, w);
  for (int i = 1; i <= n; i++) {
    R(a[i]);
    a[i - 1] -= a[i];
  }
  for (int i = 1; i <= w; i++) {
    R(b[i]);
    b[i - 1] -= b[i];
  }
  if (w == 1) {
    W(n);
    return;
  } else {
    W(kmp(n - 1, w - 1));
  }
}
