#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, ans, x, y;
int a[1000000], p[1000000];
vector<int> b;
int main() {
  cin >> n >> m;
  scanf("%d", &x);
  for (i = 0; i < n - 1; i++) {
    scanf("%d", &y);
    a[i] = y - x;
    x = y;
  }
  scanf("%d", &x);
  for (i = 0; i < m - 1; i++) {
    scanf("%d", &y);
    b.push_back(y - x);
    x = y;
  }
  n--, m--;
  b.push_back(1000000000);
  for (i = 0; i < n; i++) b.push_back(a[i]);
  for (i = 1; i < b.size(); i++) {
    while (k > 0 && b[i] != b[k]) k = p[k - 1];
    if (b[i] == b[k]) k++;
    p[i] = k;
  }
  int ans = 0;
  for (i = m; i < b.size(); i++) {
    if (p[i] >= m) ans++;
  }
  cout << ans << endl;
  return 0;
}
