#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (n == 1)
    cout << 0 << "\n";
  else {
    int a[n];
    vector<int> dp(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    int mx = 0;
    dp[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
      for (int j = i + 1; j < n; j++) {
        if (abs(a[i] - a[j]) <= k) {
          dp[i] = dp[j] + 1;
          mx = max(dp[i], mx);
          break;
        }
      }
    }
    if (mx == 0)
      cout << mx << "\n";
    else
      cout << mx + 1 << "\n";
  }
  return 0;
}
