import sys


def main():
    n, k = map(int, sys.stdin.buffer.readline().split())
    ans = {}
    for i in sys.stdin.buffer.readlines():
        i = int(i)
        chk = True
        for x in ans.keys():
            if abs(ans[x][-1] - i) <= k:
                ans[x].append(i)
                chk = False
        if chk:
            ans.setdefault(i, []).append(i)
    print(max(len(i) for i in ans.values()))


if __name__ == "__main__":
    main()
