#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200010], b[200010];
int nxt[200010];
void make_next() {
  int i = 0, j = -1;
  nxt[0] = -1;
  while (i < m) {
    if (j == -1 || b[i] == b[j]) {
      i++;
      j++;
      if (b[i] == b[j])
        nxt[i] = nxt[j];
      else
        nxt[i] = j;
    } else
      j = nxt[j];
  }
}
int kmp() {
  int i = 0, j = 0;
  int cnt = 0;
  while (i < n) {
    if (a[i] == b[j]) {
      i++;
      j++;
      if (j == m) {
        cnt++;
      }
    } else {
      j = nxt[j];
      if (j == -1) {
        i++;
        j = 0;
      }
    }
  }
  return cnt;
}
int main() {
  int i, j;
  while (cin >> n >> m) {
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < m; i++) cin >> b[i];
    if (n < m) {
      cout << "0\n";
      continue;
    } else if (m == 1) {
      cout << n << endl;
      continue;
    }
    for (i = 0; i < n - 1; i++) a[i] = a[i + 1] - a[i];
    for (i = 0; i < m - 1; i++) b[i] = b[i + 1] - b[i];
    m--;
    n--;
    make_next();
    cout << kmp() << endl;
  }
  return 0;
}
