n, k = map(int, input().split())
a = [int(input()) for _i in range(n)]+[float('inf')]

checker = [-1]*n
r = []
for i in range(n):
    if checker[i] > 0:
        continue
    c = 1
    num = a[i]
    checker[i] = 1
    for j in range(i+1, n):
        if abs(num-a[j])<=k:
            c += 1
            checker[j] = 1
            num = a[j]
    r.append(c)
print(max(r))