#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e8;
const int MAX = 200003;
int str[MAX], pat[MAX];
int fail[MAX];
int getlen(int l, int c) {
  while (l && pat[l] != c) l = fail[l - 1];
  if (pat[l] == c) l++;
  return l;
}
int n, m;
int res = 0;
void build() {
  fail[0] = 0;
  int l = 0;
  for (int i = 1; i < m - 1; i++) {
    l = getlen(l, pat[i]);
    fail[i] = l;
  }
}
void match() {
  build();
  int l = 0;
  for (int i = 0; i < n - 1; i++) {
    l = getlen(l, str[i]);
    if (l == m - 1) {
      res++;
      l = fail[l - 1];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  int prev, cur;
  scanf("%d", &prev);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &cur);
    str[i] = cur - prev;
    prev = cur;
  }
  scanf("%d", &prev);
  for (int i = 0; i < m - 1; i++) {
    scanf("%d", &cur);
    pat[i] = cur - prev;
    prev = cur;
  }
  match();
  cout << res << endl;
  return 0;
}
