#include <bits/stdc++.h>
using namespace std;
int lis(int arr[], int n, int k) {
  int lis[n];
  lis[0] = 1;
  for (int i = 1; i < n; i++) {
    lis[i] = 1;
    for (int j = 0; j < i; j++)
      if (abs(arr[i] - arr[j]) <= k && lis[i] < lis[j] + 1) lis[i] = lis[j] + 1;
  }
  return *max_element(lis, lis + n);
}
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  printf("%d\n", lis(arr, n, k));
  return 0;
}
