import sys

N, K = list(map(int, sys.stdin.readline().strip().split(" ")))


data = []
for n in range(N):
    n = int(sys.stdin.readline().strip())
    if len(data) == 0:
        data.append([n])
    else:
        checked = [True] * len(data)
        for i, d in enumerate(data):
            if abs(n - d[-1]) <= K:
                data[i].append(n)
            else:
                checked[i] = False
        lens = []
        for i, c in enumerate(checked):
            if c:
                lens.append(len(data[i]))
            else:
                lens.append(-1)
        if len(lens) > 1:
            m = -1
            mi = -1
            for i, l in lens:
                if m < l:
                    m = l
                    mi = i
            data = [d for i, d in enumerate(data) if not (checked[i] and lens[i] != m)]


print(max([len(d) for d in data]))
