#include <bits/stdc++.h>
using namespace std;
vector<long long int> pattern;
long long int kmp[200005];
vector<long long int> arr;
long long int n;
long long int w;
void build() {
  memset(kmp, 0, sizeof(kmp));
  long long int i = 1;
  long long int len = 0;
  while (i < w) {
    if (pattern[i] == pattern[len]) {
      len++;
      kmp[i] = len;
      i++;
    } else {
      if (len == 0)
        i++;
      else
        len = kmp[len - 1];
    }
  }
  return;
}
long long int matches() {
  if (pattern.size() == 0 || arr.size() == 0) return arr.size() + 1;
  long long int answer = 0;
  long long int i = 0;
  long long int j = 0;
  while (i < n) {
    if (arr[i] == pattern[j]) {
      i++;
      j++;
      if (j == w) {
        answer++;
        j = kmp[j - 1];
      }
    } else {
      if (j == 0)
        i++;
      else
        j = kmp[j - 1];
    }
  }
  return answer;
}
int32_t main() {
  cin >> n >> w;
  long long int arr1[n];
  long long int arr2[w];
  for (long long int i = 0; i < n; i++) cin >> arr1[i];
  for (long long int i = 0; i < w; i++) cin >> arr2[i];
  for (long long int i = 1; i < n; i++) {
    arr.push_back(arr1[i] - arr1[i - 1]);
  }
  for (long long int i = 1; i < w; i++) {
    pattern.push_back(arr2[i] - arr2[i - 1]);
  }
  n = n - 1;
  w = w - 1;
  build();
  cout << matches();
}
