#include <bits/stdc++.h>
using namespace std;
int Power(int a, int b) {
  if (b == 0) return a;
  if (b & 1) return a * Power(a, b - 1);
  int t = Power(a, b / 2);
  return t * t;
}
int GCD(int a, int b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
int build(int arr[], int cache[], int i, int n, int k) {
  if (i >= n) return 0;
  if (cache[i] != -1) return cache[i];
  int ans = build(arr, cache, i + 1, n, k);
  int j = i + 1;
  while (j < n) {
    if (abs(arr[j] - arr[i]) <= k) break;
    j++;
  }
  ans = max(ans, build(arr, cache, j, n, k) + 1);
  cache[i] = ans;
  return ans;
}
void solve() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int cache[n];
  memset(cache, -1, sizeof(cache));
  cout << build(arr, cache, 0, n, k);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
