#include <bits/stdc++.h>
using namespace std;
void walls(istream& r, ostream& w) {
  int b, e;
  r >> b >> e;
  int* bWall = new int[b];
  int* eWall = new int[e];
  int* bWall2 = new int[b];
  int* eWall2 = new int[e];
  for (int i = 0; i < b; ++i) {
    r >> bWall[i];
    if (i) bWall2[i - 1] = bWall[i] - bWall[i - 1];
  }
  for (int i = 0; i < e; ++i) {
    r >> eWall[i];
    if (i) eWall2[i - 1] = eWall[i] - eWall[i - 1];
  }
  int* next = new int[e];
  if (e == 1) {
    w << b << endl;
    return;
  }
  next[0] = -1;
  int index = 0;
  next[1] = 0;
  for (int i = 2; i < e; i++) {
    while (index >= 0 && eWall2[index] != eWall2[i - 1]) index = next[index];
    next[i] = ++index;
  }
  int l1 = 0, l2 = 0;
  int counter = 0;
  while (l1 < b - 1) {
    if (bWall2[l1] == eWall2[l2] || l2 == -1) {
      l1++;
      l2++;
      if (l2 == e - 1) {
        counter++;
        l2 = next[l2];
      }
    } else
      l2 = next[l2];
  }
  w << counter << endl;
}
int main() {
  walls(cin, cout);
  return 0;
}
