#include <bits/stdc++.h>
using namespace std;
void pfunc(vector<long int> &arr, vector<long int> &key, long int n, int check,
           int &count) {
  long int len = arr.size();
  long int hold = arr[len - 1];
  while (hold > 0 and key[hold] != n) {
    hold = arr[hold - 1];
  }
  if (key[hold] == n) {
    hold++;
  }
  arr.push_back(hold);
  key.push_back(n);
  if (hold == check) {
    count++;
  }
}
int main() {
  int n, w;
  int count = 0;
  cin >> n >> w;
  if (w == 1) {
    cout << n;
  } else if (n < w) {
    cout << 0;
  } else {
    vector<long int> store;
    long int hold;
    for (int i = 0; i < n; i++) {
      cin >> hold;
      store.push_back(hold);
    }
    long int base;
    vector<long int> p;
    vector<long int> key;
    cin >> base;
    cin >> hold;
    key.push_back(base - hold);
    p.push_back(0);
    base = hold;
    for (int i = 0; i < w - 2; i++) {
      cin >> hold;
      pfunc(p, key, base - hold, w - 1, count);
      base = hold;
    }
    pfunc(p, key, 2e9 + 1, w - 1, count);
    base = store[0];
    for (int i = 1; i < n; i++) {
      pfunc(p, key, base - store[i], w - 1, count);
      base = store[i];
    }
    cout << count;
  }
}
