n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]
m = 0
for i in range(n-1):
    j = i
    l = i + 1
    count = 1
    while l < n:
        if abs(a[j] - a[l]) <= k:
            count += 1
            j = l
            l += 1
        else:
            l += 1
    m = max(m, count)

print(m)