

n,k = map(int,input().split())
a=[0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
rank=[0 for i in range(n)]

rank[0]=1
for i in range(1,n):
    ap = a[i]
    r=0
    for j in range(i):
        if abs(a[j]-ap)<=k:
            r=max(r,rank[j])
    rank[i]=r+1
print(max(rank))