#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long result = 1;
  while (b > 0) {
    if ((b & 1) == 1) {
      result = result * a;
    }
    a = a * a;
    b = b >> 1;
  }
  return result;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long* arr = new long long[n];
  long long* dp = new long long[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    int x = arr[i];
    if (x < 0) {
      x *= (-1);
    }
    if (x <= k) {
      dp[i] = 1;
    } else {
      dp[i] = 0;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      long long sum = arr[i] - arr[j];
      if (sum < 0) {
        sum *= (-1);
      }
      if (sum <= k) {
        dp[i] = max(dp[j] + 1, dp[i]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(dp[i], ans);
  }
  cout << ans;
  delete[] arr;
  delete[] dp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
