#include <bits/stdc++.h>
using namespace std;
int lps[200100];
int n, w;
int a[200100], b[200100];
void comp() {
  lps[0] = 0;
  int len = 0;
  for (int i = 1; i < w; ++i) {
    if (b[i] == b[len]) {
      len++;
      lps[i] = len;
    } else {
      if (len == 0)
        lps[i] = 0;
      else {
        len = lps[len - 1];
        i--;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> w;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < w; ++i) {
    cin >> b[i];
  }
  n--, w--;
  for (int i = 0; i < n; ++i) {
    a[i] -= a[i + 1];
  }
  for (int i = 0; i < w; ++i) {
    b[i] -= b[i + 1];
  }
  comp();
  if (w == 0) {
    cout << n + 1 << "\n";
    return 0;
  }
  int l = 0, la = a[0] - b[0], c = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[l]) {
      l++;
      if (l == w) {
        c++, l = lps[l - 1];
      }
    } else {
      if (l != 0) i--, l = lps[l - 1];
    }
  }
  cout << c << '\n';
  return 0;
}
