#include <bits/stdc++.h>
using namespace std;
void debug(int* a, int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << '\n';
}
void debug(vector<int> b, int n) {
  for (int i = 0; i < n; i++) cout << b[i] << " ";
  cout << '\n';
}
const long long INF = 1e18;
const int inf = 1e9;
long long m, n;
long long lps[200005];
long long pat[200005];
long long txt[200005], ans = 0;
void computeLPSArray();
void KMPSearch() {
  computeLPSArray();
  long long i = 0;
  long long j = 0;
  while (i < n) {
    if (pat[j] == txt[i]) {
      j++;
      i++;
    }
    if (j == m) {
      ans++;
      j = lps[j - 1];
    } else if (i < n && pat[j] != txt[i]) {
      if (j != 0)
        j = lps[j - 1];
      else
        i = i + 1;
    }
  }
}
void computeLPSArray() {
  long long len = 0;
  lps[0] = 0;
  long long i = 1;
  while (i < m) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int main() {
  long long i;
  cin >> n >> m;
  long long a[200005], b[200005];
  if (m > n) {
    cout << "0" << endl;
    return 0;
  }
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n - 1; i++) {
    txt[i] = a[i] - a[i + 1];
  }
  for (i = 0; i < m - 1; i++) {
    pat[i] = b[i] - b[i + 1];
  }
  n--;
  m--;
  KMPSearch();
  cout << ans << endl;
  return 0;
}
