N, K = map(int, input().split())
dp = [1] * (N+1)
A = [0, int(input())]
for i in range(2, N+1):
    A.append(int(input()))
    t = 0
    for j in range(i-1, 0, -1):
        if abs(A[j] - A[i]) <= K:
            t = max(t, dp[j])
    dp[i] = t + 1

print(dp[N])
