#include <bits/stdc++.h>
using namespace std;
vector<long long> LpsArray(vector<long long> elephm) {
  vector<long long> lps(elephm.size());
  int idx = 0;
  for (int i = 1; i < elephm.size();) {
    if (elephm[idx] == elephm[i]) {
      lps[i] = idx + 1;
      ++idx;
      ++i;
    } else {
      if (idx != 0) {
        idx = lps[idx - 1];
      } else {
        lps[i] = idx;
        ++i;
      }
    }
  }
  return lps;
}
long long Match(vector<long long> wallm, vector<long long> elephm) {
  vector<long long> lps = LpsArray(elephm);
  int i = 0, j = 0, cnt = 0, sign = 0;
  while (i < wallm.size()) {
    if (wallm[i] == elephm[j]) {
      ++i;
      ++j;
    } else {
      if (j != 0) {
        j = lps[j - 1];
      } else {
        ++i;
      }
    }
    if (j == elephm.size()) {
      cnt++;
      sign = 1;
      j = lps[j - 1];
    }
  }
  if (!sign) return 0;
  if (sign) return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<long long> wall, eleph, wallm, elephm;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    wall.emplace_back(x);
  }
  for (int i = 1; i <= k; ++i) {
    int y;
    cin >> y;
    eleph.emplace_back(y);
  }
  for (int i = 0; i < wall.size() - 1; ++i)
    wallm.emplace_back(wall[i] - wall[i + 1]);
  for (int i = 0; i < eleph.size() - 1; ++i)
    elephm.emplace_back(eleph[i] - eleph[i + 1]);
  if (eleph.size() > wall.size())
    cout << 0 << endl;
  else if (eleph.size() == 1)
    cout << wall.size() << endl;
  else {
    long long tot = Match(wallm, elephm);
    cout << tot << endl;
  }
}
