#include <bits/stdc++.h>
const long double eps = 1e-9;
using namespace std;
template <class T>
inline T MAX(const T &_a, const T &_b) {
  return ((_a > _b) ? _a : _b);
}
template <class T>
inline T MIN(const T &_a, const T &_b) {
  return ((_a < _b) ? _a : _b);
}
template <class T>
inline T MAX3(const T &_a, const T &_b, const T &_c) {
  return MAX(MAX(_a, _b), _c);
}
template <class T>
inline T MIN3(const T &_a, const T &_b, const T &_c) {
  return MIN(MIN(_a, _b), _c);
}
template <class T>
inline T MAX4(const T &_a, const T &_b, const T &_c, const T &_d) {
  return MAX(MAX3(_a, _b, _c), _d);
}
template <class T>
inline T MIN4(const T &_a, const T &_b, const T &_c, const T &_d) {
  return MIN(MIN3(_a, _b, _c), _d);
}
template <class T>
inline T ABS(const T &_a) {
  return ((_a < 0) ? -_a : _a);
}
template <class T>
inline T SQR(const T &_a) {
  return _a * _a;
}
template <class T>
inline T gcd(T _a, T _b) {
  for (T _r; (_r = _a % _b); _b = _r) _a = _b;
  return _b;
}
template <class T>
inline T lcm(const T &_a, const T &_b) {
  return (_a / gcd(_a, _b)) * _b;
}
template <class T>
inline bool BETW(const T &_a, const T &_b, const T &_c) {
  return (_a >= MIN(_b, _c) && _a <= MAX(_b, _c));
}
template <class T>
inline bool EXT(const T &_a, const T &_b, const T &_c) {
  return !BETW(_a, _b, _c);
}
vector<int> ZFunction(const vector<int> &V) {
  int i, l = -1, r = -1, N = (int)V.size();
  vector<int> Z(N);
  Z[0] = -1;
  for (i = 1; i < N; ++i) {
    if (i > r) {
      Z[i] = 0;
      while (Z[i] + i < N && V[Z[i]] == V[i + Z[i]]) ++Z[i];
      l = i, r = Z[i] + i - 1;
    } else {
      if (Z[i - l] + i - 1 < r)
        Z[i] = Z[i - l];
      else {
        Z[i] = r - i + 1;
        while (Z[i] + i < N && V[Z[i]] == V[i + Z[i]]) ++Z[i];
        l = i, r = Z[i] + i - 1;
      }
    }
  }
  return Z;
}
int main() {
  int N, W, x, i, ans = 0;
  vector<int> T, P, Z, Dp;
  ios::sync_with_stdio(false);
  cin >> N >> W;
  if (W == 1) {
    cout << N;
    return 0;
  }
  for (i = 0; i < N; ++i) {
    cin >> x;
    T.push_back(x);
  }
  for (i = 0; i < W; ++i) {
    cin >> x;
    P.push_back(x);
  }
  for (i = 1; i < W; ++i) Dp.push_back(P[i] - P[i - 1]);
  Dp.push_back(INT_MAX);
  for (i = 1; i < N; ++i) Dp.push_back(T[i] - T[i - 1]);
  Z = ZFunction(Dp);
  for (i = 2; i < ((int)Z.size()); ++i)
    if (Z[i] >= W - 1) ++ans;
  cout << ans;
  return 0;
}
