#include <bits/stdc++.h>
const int MAXN = 200005;
int s[MAXN];
int p[MAXN];
int next[MAXN];
int n, m;
int cmp(int i, int j, int a[], int b[]) {
  if (j == 1) return 1;
  return a[i] - b[j] == a[i - 1] - b[j - 1];
}
void get_next() {
  next[1] = 0;
  int j = 0;
  for (int i = (2); i <= (m); ++i) {
    while (j && !cmp(i, j + 1, p, p)) j = next[j];
    if (cmp(i, j + 1, p, p)) ++j;
    next[i] = j;
  }
}
void get_kmp() {
  int ans = 0;
  int j = 0;
  for (int i = (1); i <= (n); ++i) {
    while (j && !cmp(i, j + 1, s, p)) j = next[j];
    if (cmp(i, j + 1, s, p)) {
      ++j;
      if (j == m) {
        ++ans;
        j = next[j];
      }
    } else
      j = next[j];
  }
  printf("%d\n", ans);
}
void solve() {
  for (int i = (1); i <= (n); ++i) scanf("%d", &s[i]);
  for (int i = (1); i <= (m); ++i) scanf("%d", &p[i]);
  get_next();
  get_kmp();
}
int main() {
  while (~scanf("%d%d", &n, &m)) solve();
  return 0;
}
