#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n], b[m], c[n - 1], d[m];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  if (m == 1)
    cout << n;
  else {
    for (int i = 0; i < n - 1; i++) c[i] = a[i + 1] - a[i];
    for (int i = 0; i < m - 1; i++) d[i] = b[i + 1] - b[i];
    d[m - 1] = 1000000000;
    int pi[m];
    pi[0] = 0;
    int i = 1, j = 0;
    for (; i < m; i++) {
      j = pi[i - 1];
      while (j && d[i] != d[j]) j = pi[j - 1];
      if (d[i] == d[j])
        pi[i] = j + 1;
      else
        pi[i] = 0;
    }
    i = 0, j = 0;
    int count = 0;
    for (; i < n - 1; i++) {
      while (j && c[i] != d[j]) j = pi[j - 1];
      if (c[i] == d[j]) j++;
      if (j == m - 1) ++count;
    }
    cout << count;
  }
  return 0;
}
