#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * (2 * 1e+5 + 5);
int mas[MAXN];
int prefix[MAXN];
int main() {
  int n, w;
  cin >> n >> w;
  int a, b;
  for (int i = w; i < w + n; ++i) {
    cin >> b;
    if (i != w) {
      mas[i - 1] = a - b;
    }
    a = b;
  }
  for (int i = 0; i < w; ++i) {
    cin >> b;
    if (i != 0) {
      mas[i - 1] = a - b;
    }
    a = b;
  }
  if (w == 1) {
    cout << n;
    return 0;
  }
  if (n < w) {
    cout << 0;
    return 0;
  }
  mas[w - 1] = INT_MAX;
  int res = 0;
  prefix[0] = 0;
  for (int i = 1; i < w + n - 1; ++i) {
    int j = prefix[i - 1];
    while (j > 0 && mas[j] != mas[i]) {
      j = prefix[j - 1];
    }
    if (mas[j] == mas[i]) {
      j++;
    }
    prefix[i] = j;
    if (j == w - 1 && i > w - 1) {
      res++;
    }
  }
  cout << res;
  return 0;
}
