#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn], b[maxn], Next[maxn], x[maxn], y[maxn];
void getnext(int m) {
  Next[1] = Next[2] = 1;
  for (int i = 2; i < m; i++) {
    int j = Next[i];
    while (j > 1 && b[i] != b[j]) j = Next[j];
    Next[i + 1] = (b[i] == b[j] ? j + 1 : 1);
  }
}
void KMP(int n, int m) {
  getnext(m);
  int ans = 0, j = 1;
  for (int i = 1; i < n; i++) {
    while (j > 1 && b[j] != a[i]) j = Next[j];
    if (a[i] == b[j]) j++;
    if (j == m) {
      ans++;
      j = Next[j];
    }
  }
  printf("%d\n", ans);
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    if (i) a[i] = x[i] - x[i - 1];
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &y[i]);
    if (i) b[i] = y[i] - y[i - 1];
  }
  if (m > 1)
    KMP(n, m);
  else
    printf("%d\n", n);
  return 0;
}
