
N,K= [int(x) for x in input().split()]

l = [1]*N

num = []

for i in range(N):
    num.append(int(input()))

print(num)

for i in range(N-1):
#    print(l)
    for j in range(i+1,N):
        if (abs(num[i]-num[j])<= K):
            if(l[i] >= l[j]):
                l[j] = l[i]+1
                break
print(max(l))
