#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T> readVector(int n) {
  vector<T> res(n);
  for (int i = 0; i < n; i++) cin >> res[i];
  return res;
}
vector<int> zFunction(vector<int> &s) {
  int n = (int)s.size();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
int findNumberOfOccurences(vector<int> &v, vector<int> &pattern) {
  if (pattern.size() == 0) return v.size() + 1;
  vector<int> str = pattern;
  str.insert(str.end(), v.begin(), v.end());
  vector<int> z = zFunction(str);
  int result = 0;
  for (int i = pattern.size(); i < z.size(); i++) {
    if (z[i] >= pattern.size()) result++;
  }
  return result;
}
vector<int> toDiffArray(vector<int> &v) {
  vector<int> result;
  for (int i = 1; i < v.size(); i++) result.push_back(v[i] - v[i - 1]);
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> a = readVector<int>(n);
  vector<int> b = readVector<int>(m);
  vector<int> aDiff = toDiffArray(a);
  vector<int> bDiff = toDiffArray(b);
  int result = findNumberOfOccurences(aDiff, bDiff);
  cout << result;
}
