#include <bits/stdc++.h>
using namespace std;
int solve(int arr[], int k, int n) {
  int dp[n];
  for (int i = 0; i < n; i++) dp[i] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (abs(arr[i] - arr[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  int ans = 1;
  for (int i = 0; i < n; i++)
    if (ans < dp[i]) ans = dp[i];
  return ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(a, k, n);
  return 0;
}
