#include <bits/stdc++.h>
#pragma warning(disable : 4996)
int n, w, a[200002], b[200002], da[200002], db[200002], next[200002];
template <class _PTy, class _NTy>
inline void getnext(const _PTy* const _Pattern, _NTy* const _Next,
                    const size_t& _PatternLen) {
  size_t i = 1;
  _NTy j = 0;
  _Next[1] = 0;
  while (i <= _PatternLen) {
    if (j == 0 || _Pattern[i] == _Pattern[j]) {
      ++i, ++j, _Next[i] = j;
    } else
      j = _Next[j];
  }
}
template <class _TTy, class _PTy, class _NTy, class _RTy = unsigned>
inline _RTy KMP(const _TTy* const _Target, const _PTy* const _Pattern,
                _NTy* const _Next, const size_t& _TargetLen,
                const size_t& _PatternLen) {
  _RTy c = 0;
  size_t i = 1;
  _NTy j = 1;
  _Next[1] = 0, getnext(_Pattern, _Next, _PatternLen);
  while (i <= _TargetLen) {
    if (j == 0 || _Target[i] == _Pattern[j]) {
      ++i, ++j;
    } else
      j = _Next[j];
    if (j > _PatternLen) {
      ++c, j = _Next[j];
    }
  }
  return c;
}
int main() {
  scanf("%d%d", &n, &w);
  if (w == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= w; ++i) scanf("%d", &b[i]);
  for (int i = 2; i <= n; ++i) da[i] = a[i] - a[i - 1];
  for (int i = 2; i <= w; ++i) db[i] = b[i] - b[i - 1];
  printf("%u\n", KMP(da + 1, db + 1, next, n - 1, w - 1));
  return 0;
}
