#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int read() {
  int x = 0;
  char c = getchar();
  while (c < 48 || c > 57) c = getchar();
  while (c > 47 && c < 58) x *= 10, x += c - 48, c = getchar();
  return x;
}
void print(int x) { printf("%d\n", x); }
int b[1000002];
void Preprocess(deque<int> &s) {
  int i = 0, j = -1;
  b[i] = j;
  while (i < s.size()) {
    while (j >= 0 && s[i] != s[j]) j = b[j];
    i++;
    j++;
    b[i] = j;
  }
}
int Search(deque<int> &s, deque<int> t) {
  int ans = 0;
  int i = 0, j = 0;
  while (i < t.size()) {
    while (j >= 0 && t[i] != s[j]) j = b[j];
    i++;
    j++;
    if (j == s.size()) ans++, j = b[j];
  }
  return ans;
}
int main() {
  int n = read(), k = read();
  if (k == 1) {
    print(n);
    return 0;
  }
  deque<int> a(n), d(k);
  for (int i = 0; i < n; i++) a[i] = read();
  for (int i = n - 1; i > 0; i--) a[i] -= a[i - 1];
  a.pop_front();
  for (int i = 0; i < k; i++) d[i] = read();
  for (int i = k - 1; i > 0; i--) d[i] -= d[i - 1];
  d.pop_front();
  Preprocess(d);
  int ans = Search(d, a);
  print(ans);
}
