#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { int N, K; cin >> N >> K; vector X(N); for (int i = 0; i < N; i++) { cin >> X[i]; } X.push_back(INFL); vector dp(N + 1, -INF); dp[0] = 0; for (int i = 0; i < N; i++) { int idx = lower_bound(X.begin(), X.end(), X[i] + K) - X.begin(); dp[idx] = max(dp[idx], dp[i] + 1); } cout << dp[N] << endl; }