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