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

a = []
for _ in range(n):
    a.append(int(input()))
b = [a[0]]
ans = [1]
for i in range(1, n):
    flag = False
    for bi in range(len(b)):
        if abs(a[i] - b[bi]) <= k:
            ans[bi] += 1
            b[bi] = a[i]
            flag = True
    if not flag:
        b.append(a[i])
        ans.append(1)
print(max(ans))
