#include <bits/stdc++.h>
using namespace std;
int *compute_lps(vector<int> &pat);
int search_kmp(vector<int> &txt, vector<int> &pat, int *lps);
int main() {
  int n, m;
  cin >> n >> m;
  int a[n], b[m];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  vector<int> txt, pat;
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) txt.push_back(a[i] - a[i + 1]);
  for (int i = 0; i < m - 1; i++) pat.push_back(b[i] - b[i + 1]);
  int *lps = compute_lps(pat);
  int cnt = search_kmp(txt, pat, lps);
  cout << cnt << endl;
  return 0;
}
int *compute_lps(vector<int> &pat) {
  int m = (int)pat.size();
  int *lps = (int *)malloc(sizeof(int) * m);
  ;
  lps[0] = 0;
  int j = 0;
  for (int i = 1; i < m; i++) {
    while (j > 0 && pat[i] != pat[j]) j = lps[j - 1];
    if (pat[i] == pat[j]) j++;
    lps[i] = j;
  }
  return lps;
}
int search_kmp(vector<int> &txt, vector<int> &pat, int *lps) {
  int n = (int)txt.size();
  int m = (int)pat.size();
  int cnt = 0, i = 0, j = 0;
  while (i < n) {
    if (txt[i] == pat[j]) {
      i++;
      j++;
    }
    if (j == m) {
      cnt++;
      j = lps[j - 1];
    }
    if (txt[i] != pat[j]) {
      if (j != 0)
        j = lps[j - 1];
      else
        i++;
    }
  }
  return cnt;
}
