#include <bits/stdc++.h>
using namespace std;
int m, n;
long long mas[300007];
long long ex[300007];
vector<long long> s;
int main() {
  scanf("%d %d", &m, &n);
  for (int i = 0; i < m; i++) {
    scanf("%I64d", &mas[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &ex[i]);
  }
  n--;
  m--;
  for (int i = 0; i < n; i++) {
    ex[i] = ex[i + 1] - ex[i];
    s.push_back(ex[i]);
  }
  s.push_back((long long)1000000000000);
  for (int i = 0; i < m; i++) {
    mas[i] = mas[i + 1] - mas[i];
    s.push_back(mas[i]);
  }
  m = n + m + 1;
  vector<int> z(m);
  for (int i = 1, l = 0, r = 0; i < m; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < m && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  int c = 0;
  for (int i = n; i < m; i++)
    if (z[i] >= n) c++;
  cout << c;
}
