n, k = map(int, input().split())
numl = [0]*n
lenl = [0] * n
for i in range(n):
    numl[i] = int(input())
    temp = 0
    for j in range(0, i):
        if(abs(numl[j] - numl[i])<=k ):
            if(lenl[j] > temp):
                temp = lenl[j]
    lenl[i] = temp+1
print(max(lenl))