n,k=map(int, input().split())
a=[int(input()) for i in range(n)]
i,j=0,1
maxs=0
lis=[]
for i in range(n):
    cnt=1
    while i<n-1:
        if abs(a[i+j]-a[i])<=k:
            #lis.append(a[i+j])
            #print(lis)
            cnt+=1
            i+=j
            j=1
        else:
            j+=1
    maxs=max(maxs,cnt)
print(maxs)