#include <bits/stdc++.h>
using namespace std;
int KMP(vector<int> T, vector<int> P) {
  vector<int> B((int)P.size() + 1, -1);
  for (int i = 0, j = -1; i < (int)P.size(); i++) {
    while (j != -1 && P[i] != P[j]) j = B[j];
    j++;
    B[i + 1] = j;
  }
  int ans = 0;
  for (int i = 0, j = 0; i < (int)T.size(); i++) {
    while (j != -1 && T[i] != P[j]) j = B[j];
    j++;
    if (j == (int)P.size()) ans++, j = B[j];
  }
  return ans;
}
int main() {
  int n, w, a, b;
  vector<int> v1, v2, ans;
  scanf("%d %d %d", &(n), &(w), &(a));
  for (int(i) = (1); (i) < (n); (i)++) {
    scanf("%d", &(b));
    v1.push_back(b - a);
    a = b;
  }
  scanf("%d", &(a));
  for (int(i) = (1); (i) < (w); (i)++) {
    scanf("%d", &(b));
    v2.push_back(b - a);
    a = b;
  }
  if (w == 1)
    cout << n << '\n';
  else {
    if (w > n)
      cout << 0 << '\n';
    else
      cout << KMP(v1, v2) << '\n';
  }
}
