import numpy as np
N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
dp = np.zeros(N)
dp[0] = 1
for i in range(1,N):
    P_ind = np.argsort(dp[:i])[::-1]
    P = np.sort(dp[:i])[::-1]
    dp[i] = 1
    for j in range(i-1):
        if abs(P[j]-A[i]) <= K:
            dp[i] = dp[P_ind[j]] + 1
            break
           
print(int(dp[N-1]))
