#D
n, k = map(int, input().split())
used = [0]*n
a = []
#a = [1, 5, 4, 3, 8, 6, 9, 7, 2, 4]
for i in range(n):
    temp = int(input())
    a.append(temp)


for i in range(n-1):
    if used[i]!=0: continue
    else:
        temp = a[i]
        c = i
        for j in range(i+1, n):
            if abs(temp-a[j])<=k:
                used[j]=max(used[j], used[c]+1)
                temp = a[j]
                c = j
print(max(used)+1)