n,k = map(int,input().split())
a = []
for i in range(n):
    a.append(int(input()))
b = sorted(a)
total = 0
for i in range(n-2):
    if abs(a[i]-a[i+1]) <= k:
        pass
    else:
        total += 1
        if abs(a[i]-a[i+2]) <= k:
            a[i+1] = a[i]
        else:
            pass
if abs(a[-1]-a[-2]) > k:
    total += 1

to = 0
sum = 1
for i in range(len(b)-1):
    if abs(b[i]-b[i+1]) <=k:
        sum += 1
    else:
        to = max(sum,to)
        sum = 0

print(max(len(a)-total,to))