#include <bits/stdc++.h>
using namespace std;
int a[200009], b[200009];
int da[200009], db[200009];
int s[400009];
int pi[4000009];
int main() {
  int n, m;
  cin >> n >> m;
  long long int ans = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  for (int i = 0; i + 1 < n; i++) {
    da[i] = a[i + 2] - a[i + 1];
    s[i + m] = da[i];
  }
  s[m - 1] = -1000000009;
  for (int i = 0; i + 1 < m; i++) {
    db[i] = b[i + 2] - b[i + 1];
    s[i] = db[i];
  }
  pi[0] = 0;
  for (int i = 1; i < m + n - 1; i++) {
    int j = pi[i - 1];
    while (j > 0 and s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  for (int i = 0; i < n + m - 1; i++)
    if (pi[i] == m - 1) ans++;
  cout << ans;
}
