#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int S[2 * N], T[2 * N], F[2 * N + 1];
void f(int m) {
  int i = 0, j = -1;
  F[0] = -1;
  while (i < m) {
    while (j >= 0 and S[i] != S[j]) j = F[j];
    i++;
    j++;
    F[i] = j;
  }
}
int kmp(int n, int m) {
  int i = 0, j = 0, c = 0;
  while (i < n) {
    while (j >= 0 and T[i] != S[j]) j = F[j];
    i++;
    j++;
    if (j == m) {
      c++;
      j = F[j];
    }
  }
  return c;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    int A[n], B[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 << endl;
      continue;
    }
    for (int i = 1; i < n; i++) T[i - 1] = A[i] - A[i - 1];
    for (int i = 1; i < m; i++) S[i - 1] = B[i] - B[i - 1];
    n--;
    m--;
    f(m);
    cout << kmp(n, m) << endl;
  }
  return 0;
}
