#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 15, M = 2e5 + 5;
bool is[N];
string a, b;
string get(int x) {
  string ret;
  int v = abs(x);
  while (1) {
    ret += char('0' + (v % 10));
    v /= 10;
    if (v == 0) break;
  }
  if (x < 0) ret += '-';
  reverse(ret.begin(), ret.end());
  return ret;
}
int x[M], y[M], kmp[M];
void table() {
  int pos = 1, match = 0;
  while (pos + match < b.size()) {
    if (b[pos + match] == b[match]) {
      ++match;
      kmp[pos + match - 1] = match;
    } else {
      if (match == 0)
        ++pos;
      else
        pos += match - kmp[match - 1], match = kmp[match - 1];
    }
  }
}
int sol() {
  int pos = 0, match = 0, R = 0;
  while (pos + match < a.size()) {
    if (match == b.size() && is[pos]) ++R;
    if (match != b.size() && a[pos + match] == b[match]) {
      ++match;
    } else {
      if (match == 0)
        ++pos;
      else
        pos += match - kmp[match - 1], match = kmp[match - 1];
    }
  }
  if (is[pos] && match == b.size()) ++R;
  return R;
}
int main() {
  int n, w, i;
  scanf("%d%d", &n, &w);
  for (i = 0; i < n; ++i) scanf("%d", &x[i]);
  for (i = 0; i < w; ++i) scanf("%d", &y[i]);
  is[0] = 1;
  for (i = 0; i < n - 1; ++i) {
    is[a.size()] = 1;
    a += get(x[i + 1] - x[i]);
    a += ' ';
  }
  for (i = 0; i < w - 1; ++i) {
    b += get(y[i + 1] - y[i]);
    b += ' ';
  }
  table();
  if (w == 1) {
    cout << n << endl;
    return 0;
  }
  cout << sol() << endl;
}
