import sys

# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10 ** 5 + 10)

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

def rec(pos):
    if dp[pos] != -1:
        return dp[pos]
    for nxt in range(pos + 1, n):
        if abs(a[pos] - a[nxt]) <= k:
            dp[pos] = rec(nxt) + 1
            return dp[pos]
    dp[pos] = 1
    return 1

ans = 0
for i in range(n-1, -1, -1):
    v = rec(i)
    ans = max(ans, v)
print(ans)