n, k =map(int,input().split())
a=[]
ans = 0
cnt = 0
for i in range(n):
    a.append(int(input()))

for i in range(n):
    if ans < n-i :
        b = a[i]
        cnt = 0
        for j in range(1,n):
            if abs(b-a[j]) <= k:
                b = a[j]
                cnt += 1
        else:
            ans=max(ans,cnt)


print(ans)
