#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 5;
const int oo = 1e9 + 7;
int n, m, cnt;
int a[maxN], w[maxN];
int b[maxN];
int z[maxN];
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d%d", &n, &m);
  if (m == 1) {
    printf("%d", n);
    return 0;
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= m; ++i) scanf("%d", &w[i]);
  for (int i = 2; i <= m; ++i) b[++cnt] = w[i] - w[i - 1];
  b[++cnt] = -oo;
  for (int i = 2; i <= n; ++i) b[++cnt] = a[i] - a[i - 1];
  int l = 0, r = 0;
  for (int i = 2; i <= cnt; ++i) {
    if (i > r) {
      l = r = i;
      while (r <= cnt && b[r - l + 1] == b[r]) ++r;
      z[i] = r - l;
      --r;
    } else {
      int k = i - l + 1;
      if (z[k] < r - i + 1)
        z[i] = z[k];
      else {
        l = i;
        while (r <= cnt && b[r - l + 1] == b[r]) ++r;
        z[i] = r - l;
        --r;
      }
    }
  }
  int res = 0;
  for (int i = m + 1; i <= cnt; ++i)
    if (z[i] == m - 1) ++res;
  cout << res;
  return 0;
}
