import bisect

n, k = map(int, input().split())
x = list(map(int, input().split()))

if n == 0:
    print(0)
    exit()

dp = [0] * n
pre_max = [0] * n

dp[0] = 1
pre_max[0] = 1

for i in range(1, n):
    target = x[i] - k
    # Find the rightmost index where x[j] <= target
    j = bisect.bisect_right(x, target) - 1
    if j >= 0:
        current = pre_max[j] + 1
    else:
        current = 1
    dp[i] = current
    pre_max[i] = max(pre_max[i-1], current)

print(pre_max[-1])