#include <bits/stdc++.h>
int n, m;
int a[200010], b[200010], fail[200010];
int main() {
  scanf("%d %d", &m, &n);
  --n;
  --m;
  int x, y;
  scanf("%d", &x);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &y);
    b[i] = y - x;
    x = y;
  }
  scanf("%d", &x);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &y);
    a[i] = y - x;
    x = y;
  }
  if (!n) return 0 * printf("%d\n", m + 1);
  if (!m) return 0 * printf("0\n");
  fail[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (x = fail[i]; x && a[x] != a[i]; x = fail[x])
      ;
    fail[i + 1] = (a[x] == a[i]) ? x + 1 : 0;
  }
  x = y = 0;
  for (int i = 0; i < m; ++i) {
    for (; x && (a[x] != b[i] || x >= n); x = fail[x])
      ;
    if (a[x] == b[i])
      if (++x == n) ++y;
  }
  printf("%d\n", y);
  return 0;
}
