#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, s[N], t[N], nxt[N];
int kmp() {
  for (int i = 1, j = 0; i < n; i++) {
    while (j && s[i] != s[j]) j = nxt[j];
    nxt[i + 1] = s[i] == s[j] ? ++j : 0;
  }
  int cnt = 0;
  for (int i = 0, j = 0; i < m; i++) {
    while (j && s[j] != t[i]) j = nxt[j];
    if (t[i] == s[j] && ++j == n) {
      j = nxt[j];
      cnt++;
    }
  }
  return cnt;
}
int main() {
  scanf("%d%d", &m, &n);
  if (n == 1) return printf("%d\n", m), 0;
  for (int i = 0; i < m; i++) {
    scanf("%d", &t[i]);
    if (i) t[i - 1] = t[i] - t[i - 1];
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &s[i]);
    if (i) s[i - 1] = s[i] - s[i - 1];
  }
  n--, m--;
  printf("%d\n", kmp());
  return 0;
}
