#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, z, cnt, sum, num, ans;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!('0' <= c && c <= '9')) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (('0' <= c && c <= '9')) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int mo[200005], str[200005];
int nx[200005];
inline void GetNext() {
  int i = 0, j = -1, len = m;
  nx[i] = j;
  while (i < len) {
    while (j != -1 && mo[i] != mo[j]) j = nx[j];
    nx[++i] = ++j;
  }
}
int KmpCount() {
  GetNext();
  int i = 0, j = 0, strL = n, moL = m;
  int ans = 0;
  while (i < strL) {
    while (j != -1 && mo[j] != str[i]) j = nx[j];
    i++, j++;
    if (j == moL) ans++;
  }
  return ans;
}
int main() {
  n = read(), m = read();
  if (m == 1) {
    cout << n;
    return 0;
  }
  if (n == 1) {
    cout << (m == 1);
    return 0;
  }
  for (int i = 1; i <= n; i++) str[i - 1] = read();
  n--;
  for (int i = 1; i <= n; i++) str[i - 1] -= str[i];
  for (int i = 1; i <= m; i++) mo[i - 1] = read();
  m--;
  for (int i = 1; i <= m; i++) mo[i - 1] -= mo[i];
  printf("%d\n", KmpCount());
  return 0;
}
