#include <bits/stdc++.h>
using namespace std;
const int Mint = 1000000000;
int n, m, p[200020], f[200020], d[600000];
vector<long long> a;
int main() {
  cin >> n >> m;
  for (int i(0); i < n; i++) scanf("%d", &p[i]);
  for (int i(0); i < m; i++) scanf("%d", &f[i]);
  if (m == 1) {
    cout << n;
    return 0;
  }
  if (m > n) {
    cout << 0;
    return 0;
  }
  for (int i(1); i < m; i++) a.push_back(f[i] - f[i - 1]);
  a.push_back(1000000000000000);
  for (int i(1); i < n; i++) a.push_back(p[i] - p[i - 1]);
  int ans = 0;
  d[0] = 0;
  for (int i(1); i < a.size(); i++) {
    int x = d[i - 1];
    while (x > 0 && a[i] != a[x]) x = d[x - 1];
    if (a[i] == a[x]) x++;
    d[i] = x;
    if (x == m - 1) ans++;
  }
  cout << ans;
}
