#include <bits/stdc++.h>
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const long long INFLL = 1e18;
const double PI = acos((double)-1);
inline int mult(int a, int b, int p = MOD) { return (1ll * a * b) % p; }
inline int add(int a, int b, int p = MOD) { return (1ll * a + b) % p; }
inline int fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
using namespace std;
vector<int> zfuntion(vector<int> s) {
  vector<int> res;
  int len = s.size();
  res.resize(len);
  int l = -1, r = -1;
  for (int i = 1; i < len; i++) {
    if (i > r) {
      l = r = i;
      while (r < len && s[r] == s[r - l]) r++;
      res[i] = r - l;
      r--;
    } else {
      int k = i - l;
      if (res[k] < r - i + 1)
        res[i] = res[k];
      else {
        l = i;
        while (r < len && s[r] == s[r - l]) r++;
        res[i] = r - l;
        r--;
      }
    }
  }
  return res;
}
int w, n, a[N], b[N];
int main() {
  ios::sync_with_stdio(false);
  scanf("%d %d", &w, &n);
  vector<int> dif1, dif2;
  dif1.resize(w - 1);
  dif2.resize(n - 1);
  for (int i = 0; i < w; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  for (int i = 0; i < w - 1; i++) dif1[i] = a[i] - a[i + 1];
  for (int i = 0; i < n - 1; i++) dif2[i] = b[i] - b[i + 1];
  if (n == 1) {
    printf("%d", w);
    return 0;
  }
  if (w == 1) {
    printf("0");
    return 0;
  }
  vector<int> s = dif2;
  s.push_back(INF);
  s.insert(s.end(), dif1.begin(), dif1.end());
  vector<int> ans = zfuntion(s);
  int cnt = 0;
  for (int i = n; i < ans.size(); i++)
    if (ans[i] == n - 1) cnt++;
  printf("%d", cnt);
  return 0;
}
