#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, res;
int a[N], b[N], x[N], y[N];
int nxt[N];
inline void get_nxt() {
  for (int i = 2, j; i <= m; ++i) {
    j = nxt[i - 1];
    while (j && y[i - 1] != y[j]) j = nxt[j];
    nxt[i] = j + 1;
  }
}
inline void KMP() {
  for (int i = 1, j = 1; i < n;) {
    if (x[i] == y[j]) {
      ++i, ++j;
      if (j >= m) ++res, j = nxt[j];
    } else {
      j = nxt[j];
      if (!j) ++i, ++j;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  if (m == 1) {
    cout << 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) x[i] = a[i] - a[i + 1];
  for (int i = 1; i < m; ++i) y[i] = b[i] - b[i + 1];
  get_nxt();
  KMP();
  cout << res;
  return 0;
}
