#include <bits/stdc++.h>
using namespace std;
int p[400000];
void prin(vector<int> temp) {
  int i;
  for (i = 0; i < temp.size(); i++) {
    cout << temp[i] << " ";
  }
  cout << endl;
}
int kmp(vector<int> s1, vector<int> s2) {
  int i, ret = 0;
  s2.push_back(1100000000);
  int n = s1.size();
  int m = s2.size();
  p[0] = p[1] = 0;
  int k = 0;
  for (i = 2; i <= m; ++i) {
    while (s2[i - 1] != s2[k] && k) k = p[k];
    k = k + (s2[i - 1] == s2[k]);
    p[i] = k;
  }
  k = 0;
  for (i = 0; i < n; ++i) {
    while (s1[i] != s2[k] && k) k = p[k];
    k = k + (s1[i] == s2[k]);
    if (k >= (m - 1)) {
      ret++;
    }
  }
  return ret;
}
vector<int> temp1, temp2;
int a[400000], b[400000];
int main() {
  int i, j, k, n1, n2;
  scanf("%d %d", &n1, &n2);
  for (i = 0; i < n1; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < n2; i++) {
    scanf("%d", &b[i]);
  }
  if (n2 == 1) {
    printf("%d\n", n1);
    return 0;
  }
  for (i = 1; i < n1; i++) {
    temp1.push_back(a[i - 1] - a[i]);
  }
  for (i = 1; i < n2; i++) {
    temp2.push_back(b[i - 1] - b[i]);
  }
  printf("%d\n", kmp(temp1, temp2));
  return 0;
}
