#include <bits/stdc++.h>
using namespace std;
namespace Solve {
const int MAXN = 200005;
int fail[MAXN];
void getFail(int *A, int n) {
  fail[0] = fail[1] = 0;
  int j;
  for (int i = 1; i < n; i++) {
    j = fail[i];
    while (j && A[i] != A[j]) j = fail[j];
    fail[i + 1] = j;
    if (A[i] == A[j]) fail[i + 1]++;
  }
  return;
}
int Count(int *A, int *B, int n, int m) {
  int cnt = 0, j = 0;
  for (int i = 0; i < n; i++) {
    while (j && A[i] != B[j]) j = fail[j];
    if (A[i] == B[j]) j++;
    if (j == m) cnt++, j = fail[j];
  }
  return cnt;
}
int n, w, A[MAXN], B[MAXN];
void work() {
  scanf("%d%d", &n, &w);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= w; i++) scanf("%d", &B[i]);
  if (n == 1 || w == 1) {
    printf("%d\n", n / w);
    return;
  }
  for (int i = n; i >= 1; i--) A[i] = A[i] - A[i - 1];
  for (int i = 1; i < n; i++) A[i] = A[i + 1];
  n--;
  for (int i = 0; i < n; i++) A[i] = A[i + 1];
  for (int i = w; i >= 1; i--) B[i] = B[i] - B[i - 1];
  for (int i = 1; i < w; i++) B[i] = B[i + 1];
  w--;
  for (int i = 0; i < w; i++) B[i] = B[i + 1];
  getFail(B, w);
  printf("%d\n", Count(A, B, n, w));
  return;
}
}  // namespace Solve
int main() {
  Solve::work();
  return 0;
}
