n,k = map(int,input().split())
a=[]
for i in range(n):
    a.append(int(input()))
    
dp= [0]*(n+1)
# dp[0]=1

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