#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int k[200005];
int x[200005], y[200005];
int a[200005], b[200005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= m; i++) cin >> y[i];
  if (m == 1) {
    printf("%d", n);
    return 0;
  }
  for (int i = 1; i < n; i++) a[i] = x[i + 1] - x[i];
  for (int i = 1; i < m; i++) b[i] = y[i + 1] - y[i];
  int j = 0;
  for (int i = 2; i < m; i++) {
    while (j > 0 && b[j + 1] != b[i]) j = k[j];
    if (b[j + 1] == b[i]) j++;
    k[i] = j;
  }
  j = 0;
  for (int i = 1; i < n; i++) {
    while (j > 0 && b[j + 1] != a[i]) j = k[j];
    if (b[j + 1] == a[i]) j++;
    if (j == m - 1) j = k[j], ans++;
  }
  printf("%d", ans);
  return 0;
}
