#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int t[maxn], p[maxn], f[maxn];
int n, m;
void get_fail() {
  f[0] = f[1] = 0;
  for (int i = 1; i < m; ++i) {
    int j = f[i];
    while (j && p[i] != p[j]) j = f[j];
    f[i + 1] = p[i] == p[j] ? j + 1 : 0;
  }
}
int kmp() {
  get_fail();
  int j = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    while (j && p[j] != t[i]) j = f[j];
    if (p[j] == t[i]) ++j;
    if (j == m) ++cnt;
  }
  return cnt;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> t[i];
  for (int i = 0; i < m; ++i) cin >> p[i];
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; ++i) t[i] = t[i + 1] - t[i];
  for (int i = 0; i < m - 1; ++i) p[i] = p[i + 1] - p[i];
  --n, --m;
  cout << kmp() << endl;
  return 0;
}
