n,k = map(int,input().split())
a = []
t = []

for i in range(n):
    b = int(input())
    a.append(b)

for i in range(n):
    cnt = 0
    b = a[i]
    for s in range(i,n):
        if((abs(a[s] - b)) <= k):
            cnt += 1
            b = a[s]
    
    t.append(cnt)

print(max(t))