#include <bits/stdc++.h>
using namespace std;
int dp[300005];
int ways(long long* arr, int n, int last, int k) {
  if (n == 0) {
    return 0;
  }
  if (dp[last] != -1) {
    return dp[last];
  }
  if (last == 300001) {
    int option1 = ways(arr + 1, n - 1, last, k);
    int option2 = 1 + ways(arr + 1, n - 1, arr[0], k);
    return dp[last] = max(option1, option2);
  } else {
    int option1 = ways(arr + 1, n - 1, last, k);
    int option2 = 0;
    if (abs(arr[0] - last) <= k) {
      option2 = 1 + ways(arr + 1, n - 1, arr[0], k);
    }
    return dp[last] = max(option1, option2);
  }
}
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  memset(dp, -1, sizeof(dp));
  long long* arr = new long long[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long ans = ways(arr, n, 300001, k);
  cout << ans << endl;
}
