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

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

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

print(max(t))