#include <bits/stdc++.h>
int nextInt() {
  int x;
  scanf("%d", &x);
  return x;
}
double nextDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long nextLong() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
char nextChar() {
  char x;
  scanf("%c", &x);
  return x;
}
void newLine() { printf("\n"); }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long pow(long long a, long long b, long long MOD) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
int countSetBit(long long n) {
  int ans = 0;
  while (n != 0) {
    n -= (n & -n);
    ++ans;
  }
  return ans;
}
long long mod = 1ll * 1e9 + 7;
const int N = 200100;
const int M = 100100;
using namespace std;
int main() {
  int n = nextInt(), m = nextInt();
  long long a[N], b[N], t[N];
  for (int i = 0; i <= n - 1; i++) {
    a[i] = nextLong();
  }
  for (int i = 0; i <= m - 1; i++) {
    b[i] = nextLong();
  }
  int j = -1;
  for (int i = 0; i < m; i++) {
    t[i] = j;
    while (j >= 0 && (b[i] - b[i - j]) != (b[j] - b[0])) j = t[j];
    ++j;
    if (i + 1 == m) t[i + 1] = j;
  }
  j = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    while (j >= 0 && (a[i] - a[i - j]) != (b[j] - b[0])) j = t[j];
    ++j;
    if (j == m) {
      ++cnt;
      j = t[j];
    }
  }
  cout << cnt << endl;
  return 0;
}
