#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, ans;
int shu1[maxn], shu2[maxn];
int kmp[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> shu1[i];
  for (int i = 1; i <= m; ++i) cin >> shu2[i];
  if (m == 1) {
    cout << n;
    return 0;
  }
  for (int i = 1; i < n; ++i) shu1[i] -= shu1[i + 1];
  for (int i = 1; i < m; ++i) shu2[i] -= shu2[i + 1];
  for (int i = 2, j = 0; i < m; ++i) {
    while (j && shu2[j + 1] != shu2[i]) j = kmp[j];
    if (shu2[j + 1] == shu2[i]) ++j;
    kmp[i] = j;
  }
  for (int i = 1, j = 0; i < n; ++i) {
    while (j && shu2[j + 1] != shu1[i]) j = kmp[j];
    if (shu1[i] == shu2[j + 1]) ++j;
    if (j == m - 1) j = kmp[j], ++ans;
  }
  cout << ans;
}
