#include <bits/stdc++.h>
using namespace std;
void computeLPSArray(vector<int> &pat, int M, vector<int> &lps) {
  int len = 0;
  lps[0] = 0;
  int 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 KMPSearch(vector<int> &txt, vector<int> &pat) {
  int M = pat.size(), N = txt.size(), cnt = 0;
  vector<int> lps(M);
  computeLPSArray(pat, M, lps);
  int i = 0;
  int j = 0;
  while (i < N) {
    if (pat[j] == txt[i]) {
      j++;
      i++;
    }
    if (j == M) {
      cnt++;
      j = lps[j - 1];
    } else if (i < N && pat[j] != txt[i]) {
      if (j != 0)
        j = lps[j - 1];
      else
        i = i + 1;
    }
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> arr(n), brr(m);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> brr[i];
  }
  if (m > n) {
    cout << 0 << endl;
    return 0;
  }
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  vector<int> diffa, diffb;
  for (int i = 0; i < n - 1; i++) {
    diffa.push_back(arr[i + 1] - arr[i]);
  }
  for (int i = 0; i < m - 1; i++) {
    diffb.push_back(brr[i + 1] - brr[i]);
  }
  cout << KMPSearch(diffa, diffb) << endl;
}
