N,K = map(int,input().split())
A = [int(input()) for x in range(N)]
L = []
Lkari = []
saityouL = [1]*N

def f(x):#最後がA[x]の部分数列の最長
    L = []
    a = []
    global saityouL
    for p in range(x):
        if abs(A[p]-A[x]) <= K:
            L += [p]#それより手前で絶対値が３以下の数字の場所

    if len(L) == 0:
        saityouL[x] = 1
        return 1
    else:
        for q in range(len(L)):
            a += [saityouL[L[q]]]
        saityouL[x] = max(a) + 1
        return max(a) + 1

for r in range(N):
    f(r)

print(max(saityouL))












"""
L = []
goukei = 0
goukeimax = 0

for p in range(N-1):
    if abs(A[p]-A[p+1]) <= K:
        L += [1]
    else:
        L += [0]

for q in range(N-1):
    if L[q] == 1:
        goukei += 1
    else:
        goukeimax = max(goukei,goukeimax)
        goukei = 0

print(goukeimax)
print(L)
"""