#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005];
int nx[500005];
int n, m;
void getnext() {
  nx[0] = -1;
  int j = 0, k = -1;
  while (j < m) {
    if (k == -1 || b[j] == b[k])
      nx[++j] = ++k;
    else
      k = nx[k];
  }
}
int KMP() {
  int ret = 0;
  int i = 0, j = 0;
  for (i = 0; i < n; i++) {
    while (j > 0 && a[i] != b[j]) j = nx[j];
    if (a[i] == b[j]) j++;
    if (j == m) {
      ret++;
      j = nx[j];
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) a[i - 1] = a[i] - a[i - 1];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    if (i != 0) b[i - 1] = b[i] - b[i - 1];
  }
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  n--;
  m--;
  getnext();
  cout << KMP() << endl;
  return 0;
}
