#include <bits/stdc++.h>
using namespace std;
long long dp[300010], a[300010];
int n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  cout << dp[n];
}
