#include <bits/stdc++.h>
using namespace std;
int n;
int s[1000000];
int sa[1000000];
int pos[1000000];
int tmp[1000000];
int comun[1000000];
int gap = 1;
bool compara(int i1, int i2) {
  if (pos[i1] < pos[i2]) return true;
  if (pos[i1] > pos[i2]) return false;
  i1 += gap;
  i2 += gap;
  if (i1 < n and i2 < n) return pos[i1] < pos[i2];
  return i1 > i2;
}
void computa() {
  for (int i = 0; i < n; i++) {
    sa[i] = i;
    pos[i] = s[i];
  }
  do {
    sort(sa, sa + n, compara);
    tmp[0] = 0;
    for (int i = 1; i < n; i++) tmp[i] = tmp[i - 1] + compara(sa[i - 1], sa[i]);
    for (int i = 0; i < n; i++) pos[sa[i]] = tmp[i];
    gap *= 2;
  } while (pos[sa[n - 1]] != n - 1);
}
void calculacomun() {
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (pos[i] != n - 1) {
      while (i + k < n and sa[pos[i] + 1] + k < n and
             s[i + k] == s[sa[pos[i] + 1] + k])
        k++;
      comun[pos[i]] = k;
    } else
      comun[pos[i]] = 0;
    if (k > 0) k--;
  }
}
int a[1000000];
int b[1000000];
int main() {
  ios::sync_with_stdio(false);
  int m, w;
  cin >> m >> w;
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 0; i < w; i++) cin >> b[i];
  if (w == 1) {
    cout << m << endl;
    exit(0);
  }
  n = 0;
  for (int i = 0; i < m - 1; i++) s[n++] = a[i + 1] - a[i];
  s[n++] = 1000000000;
  for (int i = 0; i < w - 1; i++) s[n++] = b[i + 1] - b[i];
  computa();
  calculacomun();
  {
    int i = pos[m];
    while (i < n - 1 and comun[i] >= w - 1) i++;
    cout << i - pos[m] << endl;
  }
}
