#include <bits/stdc++.h>
using namespace std;
int A[300010], K, N;
int dp(int pos, int num, int last) {
  if (pos == N - 1) {
    if (abs(last - A[pos]) <= K)
      return num + 1;
    else
      return num;
  }
  if (last == -1)
    return max(dp(pos + 1, num + 1, A[pos]), dp(pos + 1, num, last));
  else {
    if (abs(last - A[pos]) <= K) {
      return max(dp(pos + 1, num + 1, A[pos]), dp(pos + 1, num, last));
    } else
      return dp(pos + 1, num, last);
  }
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  cout << dp(0, 0, -1);
  return 0;
}
