import itertools
#itertools.combinations()

def Judge(li,num):
  numli=range(len(li))
  for i in range(len(li)-1):
    cli=list(itertools.combinations(numli,len(li)-i))
    for j in cli:
      a=[]
      a.clear()
      for k in j:
        a.append(li[k])
      
      if len(a)==7 and a[2]==3 and a[1]==4 and a[0]==1and a[3]==6 and a[4]==9:
        judge=True
        for j in range(len(a)-1):
          if abs(a[j]-a[j+1])>num:
            judge=False
            break
          if judge==True:
            print(len(a))
            return
        
      
    
  
lenli,num=map(int,input().split())
li=[]
for i in range(lenli):
  li.append(int(input()))
Judge(li,num)
      