import numpy as np
n, k = map(int, input().split())
l = [int(input()) for i in range(n)]
l = np.array(l)
ans = 1
dl = []
while len(l) > ans:
    mx = l[0]
    cnt = 1
    l = np.delete(l, 0)
    for i in range(len(l)):
        if abs(mx - l[i]) <= k:
            cnt += 1
            mx = l[i]
            dl.append(int(i))
    ans = max(ans, cnt)
    for j in sorted(dl, reverse=True):
        l = np.delete(l, j)
    dl = []
print(ans)
