#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e8;
const int maxn = 2e5 + 5;
int a[maxn], b[maxn], nextt[maxn - 1];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  for (int i = 0; i < m - 1; i++) {
    a[i] -= a[i + 1];
  }
  for (int i = 0; i < n - 1; i++) {
    b[i] -= b[i + 1];
  }
  n--, m--;
  int i = 0, j = -1;
  nextt[0] = -1;
  while (i < n) {
    if (j == -1 || b[i] == b[j]) {
      nextt[++i] = ++j;
    } else {
      j = nextt[j];
    }
  }
  int ans = 0;
  i = 0, j = 0;
  while (i < m) {
    if (j == -1 || a[i] == b[j]) {
      i++, j++;
    } else {
      j = nextt[j];
    }
    if (j == n) {
      ans++;
      j = nextt[j - 1];
      i--;
    }
  }
  cout << ans << endl;
}
