#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
int a[MAX], b[MAX], f[MAX];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int k = 0;
  for (int i = 1; i < m; i++) {
    while (k > 0 && b[i] - b[i - 1] != b[k] - b[k - 1]) {
      k = f[k];
    }
    k++;
    f[i + 1] = k;
  }
  int ans = 0;
  k = 0;
  for (int i = 0; i < n; i++) {
    while (k > 0 && a[i] - a[i - 1] != b[k] - b[k - 1]) {
      k = f[k];
    }
    k++;
    if (k == m) {
      ans++;
    }
  }
  cout << ans;
}
