#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod1 = 1e9 + 7;
const unsigned long long mod2 = 100000000000000013ULL;
const unsigned long long mod3 = 999999999999999989ULL;
unsigned long long modmul(unsigned long long x, unsigned long long y,
                          unsigned long long mod) {
  if (x < y) swap(x, y);
  unsigned long long res = 0;
  while (y > 0) {
    if (((y)&1)) {
      res = (res + x) % mod;
    }
    x = (x + x) % mod;
    y >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<int> a(n), b(w);
  for (int& v : a) cin >> v;
  for (int& v : b) cin >> v;
  vector<unsigned long long> da(n), db(w);
  for (int i = (1); i < (n); ++i) da[i] = (mod3 + a[i] - a[i - 1]);
  for (int i = (1); i < (w); ++i) db[i] = (mod3 + b[i] - b[i - 1]);
  unsigned long long t1 = 1, t2 = 1;
  for (int i = (0); i < (w - 1); ++i) {
    t1 = modmul(t1, mod1, mod3);
    t2 = modmul(t2, mod2, mod3);
  }
  unsigned long long ah1 = 0, bh1 = 0, ah2 = 0, bh2 = 0;
  for (int i = (1); i < (w); ++i) {
    ah1 = (modmul(ah1, mod1, mod3) + da[i]) % mod3;
    ah2 = (modmul(ah2, mod2, mod3) + da[i]) % mod3;
    bh1 = (modmul(bh1, mod1, mod3) + db[i]) % mod3;
    bh2 = (modmul(bh2, mod2, mod3) + db[i]) % mod3;
  }
  int res = 0;
  for (int i = 1; i + w - 1 <= n; ++i) {
    if (ah1 == bh1 and ah2 == bh2) ++res;
    if (i + w - 1 < n) {
      ah1 = (modmul(ah1, mod1, mod3) + da[i + w - 1] - modmul(da[i], t1, mod3) +
             mod3) %
            mod3;
      ah2 = (modmul(ah2, mod2, mod3) + da[i + w - 1] - modmul(da[i], t2, mod3) +
             mod3) %
            mod3;
    }
  }
  cout << res << endl;
}
