#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10240000000,10240000000")
using namespace std;
int S[200005], T[200005], nxt[200005];
void getNext(int tlen) {
  int j, k;
  j = 0;
  k = -1;
  nxt[0] = -1;
  while (j < tlen)
    if (k == -1 || T[j] == T[k])
      nxt[++j] = ++k;
    else
      k = nxt[k];
}
int KMP_Count(int slen, int tlen) {
  if (slen < tlen) return 0;
  if (tlen == 0) return slen + 1;
  int ans = 0;
  int i, j = 0;
  if (slen == 1 && tlen == 1) {
    if (S[0] == T[0])
      return 1;
    else
      return 0;
  }
  getNext(tlen);
  for (i = 0; i < slen; i++) {
    while (j > 0 && S[i] != T[j]) j = nxt[j];
    if (S[i] == T[j]) j++;
    if (j == tlen) {
      ans++;
      j = nxt[j];
    }
  }
  return ans;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &S[i]);
      if (i > 0) S[i - 1] = S[i] - S[i - 1];
    }
    for (int i = 0; i < m; i++) {
      scanf("%d", &T[i]);
      if (i > 0) T[i - 1] = T[i] - T[i - 1];
    }
    cout << KMP_Count(n - 1, m - 1) << endl;
  }
  return 0;
}
