#include <bits/stdc++.h>
using namespace std;
int lps[200005];
void computeLPSArray(int pat[], int M) {
  int len = 0;
  int i;
  lps[0] = 0;
  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(int pat[], int txt[], int M, int N) {
  int j = 0;
  int ans = 0;
  int i = 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;
    }
  }
  return ans;
}
int a[200005], b[200005];
int main() {
  int n, w;
  cin >> n >> w;
  if (w == 1) {
    cout << n;
    return 0;
  }
  if (n == 1) {
    cout << "0";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= w; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < w - 1; i++) {
    b[i] = b[i + 2] - b[i + 1];
  }
  for (int i = 0; i < n - 1; i++) {
    a[i] = a[i + 2] - a[i + 1];
  }
  computeLPSArray(b, w - 1);
  cout << KMPSearch(b, a, w - 1, n - 1);
  return 0;
}
