#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  if (m == 1) {
    cout << n;
    return 0;
  }
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  n--;
  for (int i = 0; i < n; i++) {
    a[i] = a[i] - a[i + 1];
  }
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  m--;
  for (int i = 0; i < m; i++) {
    b[i] = b[i] - b[i + 1];
  }
  int c[n + m + 1];
  for (int i = 0; i < m; i++) {
    c[i] = b[i];
  }
  c[m] = inf;
  for (int i = m + 1; i < n + m + 1; i++) {
    c[i] = a[i - m - 1];
  }
  int ans = 0;
  int p[n + m + 1];
  p[0] = 0;
  for (int i = 1; i < n + m + 1; i++) {
    int j = p[i - 1];
    while (j > 0 && c[i] != c[j]) {
      j = p[j - 1];
    }
    if (c[i] == c[j]) j++;
    p[i] = j;
    if (j == m) {
      ans++;
    }
  }
  cout << ans;
}
