#D
n,k = map(int,input().split())
a = [int(input()) for i in range(n)]
Max = 0
for i in range(len(a)):
    cnt = 1
    for j in range(i+1,len(a)) :
        if abs(a[i]-a[j]) <= k:
            cnt += 1
        i = j
    if Max < cnt :
        Max = cnt
        
print(Max)