from sys  import stdin,stdout

from collections import Counter

st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

from bisect import bisect_left,bisect_right

mod=1000000007
INF=float('inf')
                
def solve():
    n,k=mp()
    l=[inp() for i in range(n)]
    dp=[1 for i in range(n)]
    for i in range(1,n):
        for j in range(i):
            
            if abs(l[i]-l[j])<=k:
                dp[i]=max(dp[i],1+dp[j])
       
    pr(dp[-1])
            

    
for _ in range(1):

    solve()
