#include <bits/stdc++.h>
using namespace std;
int a[200001];
int b[200001];
int nextb[200001];
void getnext(int *t, int m, int *next) {
  int i = 1, j = 0;
  next[1] = 0;
  while (i < m) {
    if (j == 0 || t[i] == t[j])
      next[++i] = ++j;
    else
      j = next[j];
  }
}
int main() {
  int n, w, x, y;
  scanf("%d%d%d", &n, &w, &x);
  for (int i = 1; i < n; i++) {
    scanf("%d", &y);
    a[i] = y - x;
    x = y;
  }
  scanf("%d", &x);
  for (int i = 1; i < w; i++) {
    scanf("%d", &y);
    b[i] = y - x;
    x = y;
  }
  int sum = 0;
  if (n == 1)
    sum += (w == 1);
  else if (w == 1)
    sum += n;
  else if (n >= w) {
    getnext(b, w, nextb);
    int i = 1, j = 1;
    while (i < n) {
      if (j == 0) {
        j++;
        i++;
        continue;
      }
      if (n - i < w - j) break;
      if (a[i] == b[j]) {
        i++;
        j++;
        if (j >= w) {
          sum++;
          j = nextb[w - 1];
          i--;
        }
      } else {
        if (nextb[j])
          j = nextb[j];
        else {
          i++;
          j = 1;
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}
