#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-6;
const double PI = acos(-1.0);
int a[N], b[N], s[N], p[N], f[N];
int main(void) {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  if (m == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= m; ++i) scanf("%d", b + i);
  for (int i = 1; i < n; ++i) s[i] = a[i + 1] - a[i];
  for (int i = 1; i < m; ++i) p[i] = b[i + 1] - b[i];
  for (int i = 2, j = 0; i < m; ++i) {
    while (j && p[i] != p[j + 1]) j = f[j];
    if (p[i] == p[j + 1]) ++j;
    f[i] = j;
  }
  for (int i = 1, j = 0; i < n; ++i) {
    while (j && s[i] != p[j + 1]) j = f[j];
    if (s[i] == p[j + 1]) ++j;
    if (j == m - 1) {
      j = f[j];
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
