#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m, nxt[200005], len, ans;
int t[200005], p[200005], c[200005], d[200005];
void kmp() {
  for (int i = 2, k = 0; i <= len; i++) {
    while (k && d[k + 1] != d[i]) k = nxt[k];
    if (d[k + 1] == d[i]) k++;
    nxt[i] = k;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> t[i];
  for (int i = 1; i <= m; i++) cin >> p[i];
  for (int i = 1; i < n; i++) c[i] = t[i + 1] - t[i];
  for (int i = 1; i < m; i++) d[i] = p[i + 1] - p[i];
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  len = m - 1;
  n--;
  kmp();
  int i = 1, j = 1;
  while (i <= n) {
    while (j <= len && i <= n && c[i] == d[j]) {
      j++;
      i++;
    }
    if (j == 1) i++;
    if (j == len + 1) {
      ans++;
      j = nxt[j - 1] + 1;
    } else
      j = nxt[j - 1] + 1;
  }
  cout << ans << endl;
  return 0;
}
