N,K=map(int,input().split())
A=list()
for i in range(N):
    A.append(int(input()))
dp=[0]*N
dp[0]=1
for i in range(1,N):
    for j in range(i):
        if abs(A[j]-A[i])<=K:
            dp[i]=max(dp[i],dp[j]+1)
print(dp[N-1])