#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, a[N], b[N], c[N << 1], fail[N << 1], ans;
int main() {
  cin >> n >> m;
  if (m == 1) {
    cout << n;
    return 0;
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) a[i] -= a[i + 1];
  for (int i = 1; i <= m; i++) cin >> b[i];
  for (int i = 1; i < m; i++) b[i] -= b[i + 1];
  b[m] = -100, n--;
  for (int i = m + 1; i <= m + n; i++) b[i] = a[i - m];
  for (int i = 2, j = 0; i <= n + m; i++) {
    while (j && b[j + 1] != b[i]) j = fail[j];
    if (b[j + 1] == b[i]) j++;
    fail[i] = j;
    if (j == m - 1) ans++;
  }
  cout << ans;
  return 0;
}
