#include <bits/stdc++.h>
using namespace std;
int arr[200010];
int pat[200010];
int def[200010];
int patdef[200010];
int lps[200010];
int nlps[200010];
int n, m;
void kmp() {
  lps[0] = 0;
  for (int i = 1; i <= m - 1; ++i) {
    int j = lps[i - 1];
    while (j > 0 && patdef[i] != patdef[j]) {
      j = lps[j - 1];
    }
    if (patdef[i] == patdef[j] || j == 0) j++;
    lps[i] = j;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n - 1; ++i) {
    cin >> arr[i];
  }
  def[0] = 0;
  for (int i = 1; i <= n - 1; ++i) {
    def[i] = arr[i] - arr[i - 1];
  }
  patdef[0] = 0;
  for (int i = 0; i <= m - 1; ++i) {
    cin >> pat[i];
  }
  for (int i = 1; i <= m - 1; ++i) {
    patdef[i] = pat[i] - pat[i - 1];
  }
  kmp();
  int j = 0, c = 0;
  for (int i = 0; i <= n - 1; ++i) {
    while (j > 0 && def[i] != patdef[j]) j = lps[j - 1];
    if (def[i] == patdef[j] || i == 0 || j == 0) j++;
    if (j >= m) {
      c++;
      j = lps[j - 1];
    }
  }
  cout << c << "\n";
  ;
  return 0;
}
