#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 1e5 + 5;
const long long INF = 1e10;
long long n, m, a[N], b[N], p[N], cnt;
vector<long long> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  for (int i = 2; i <= m; i++) {
    v.push_back(b[i] - b[i - 1]);
  }
  v.push_back(INF);
  for (int i = 2; i <= n; i++) {
    v.push_back(a[i] - a[i - 1]);
  }
  for (int i = 1; i < v.size(); i++) {
    long long j = p[i - 1];
    while (j > 0 && v[i] != v[j]) j = p[j - 1];
    if (v[i] == v[j]) {
      j++;
    }
    p[i] = j;
  }
  for (int i = 0; i < v.size(); i++) {
    if (p[i] == m - 1) cnt++;
  }
  cout << cnt;
  return 0;
}
