#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int DX[] = {0, -1, -1, -1, 0, 1, 1, 1};
int DY[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n];
  dp[0] = 1;
  for (int i = 1; i < n; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++) {
      if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  cout << *max_element(dp, dp + n) << '\n';
}
