N,K = map(int,input().split())
A = list()
for i in range (N):
    a = int(input())
    A.append(a)
c = 0
for i in range (N):
    b = 1
    s = A[0]
    a = 1
    for i in range (len(A) - 1):
        if abs(s - A[a]) <= K:
            s = A[a]
            b = b + 1
        
        a = a + 1
    del A[0]
    if c<b:
        c = b
print(c)

