n, k = map(int, input().split())
a = [0]
for _ in range(n):
    a.append(int(input()))
# print(a)
dp = [0]*(n+1)
# dp[1] = 1

for i in range(1, n+1):
    m = 0
    for j in range(1, i):
        if abs(a[j]-a[i]) <= k:
            m = max(m, dp[j])
    dp[i] = m+1

# print(dp)
print(dp[-1])