#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> v1(n), v2(m), v3(n + m + 5);
  for (int i = 0; i < n; i++) {
    cin >> v1[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> v2[i];
  }
  if (m == 1) {
    cout << n << '\n';
    return 0;
  }
  int cr = 0;
  for (int i = 0; i < m - 1; i++, cr++) {
    v3[cr] = v2[i + 1] - v2[i];
  }
  v3[cr] = 1e9;
  cr++;
  for (int i = 0; i < n - 1; i++, cr++) {
    v3[cr] = v1[i + 1] - v1[i];
  }
  vector<int> pi(n + m + 5);
  pi[0] = 0;
  for (int i = 1; i < n + m; i++) {
    int j = pi[i - 1];
    while (j > 0 && v3[j] != v3[i]) j = pi[j - 1];
    if (v3[i] == v3[j]) pi[i] = j + 1;
  }
  int cnt = 0;
  for (int i = 0; i < n + m - 1; i++) {
    cnt += (pi[i] == m - 1);
  }
  cout << cnt << '\n';
  return 0;
}
