#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
const int INF = 2000000009;
const int MX = 100005;
const double EPS = 1e-9;
const int MOD = 1000000007;
void computeLps(vector<int> &pat, vector<int> &lps, int n) {
  int j = 0, i = 1;
  while (i < n) {
    if (pat[j] == pat[i])
      lps[i++] = ++j;
    else
      j ? j = lps[j - 1] : i++;
  }
}
int KMP(vector<int> &text, vector<int> &pat) {
  int n = (int)text.size();
  int m = (int)pat.size();
  vector<int> lps(m, 0);
  computeLps(pat, lps, m);
  int match = 0;
  int j = 0, i = 0;
  while (i < n) {
    if (text[i] == pat[j])
      i++, j++;
    else
      j ? j = lps[j - 1] : i++;
    if (j == m) match++, j = lps[j - 1];
  }
  return match;
}
int main() {
  int n = ({
    int a;
    read(a);
    a;
  }),
      w = ({
        int a;
        read(a);
        a;
      });
  vector<int> text, pat;
  int pre = ({
    int a;
    read(a);
    a;
  });
  for (int i = 1; i < n; i++) {
    int temp = ({
      int a;
      read(a);
      a;
    });
    text.push_back(temp - pre);
    pre = temp;
  }
  pre = ({
    int a;
    read(a);
    a;
  });
  for (int i = 1; i < w; i++) {
    int temp = ({
      int a;
      read(a);
      a;
    });
    pat.push_back(temp - pre);
    pre = temp;
  }
  int ans = w == 1 ? n : KMP(text, pat);
  printf("%d\n", ans);
  return 0;
}
