N, K = list(map(int, input().split()))

sequence = []
for i in range(N):

    a = int(input())
    sequence.append(a)

max_length = 0
for i in range(len(sequence)):
    answer = []
    _from = i
    _to = _from + 1
    while True:
        try:
            if abs(sequence[_from] - sequence[_to]) <= K:
                answer.append(sequence[_to])
                _from = _to
                _to += 1
            else:
                _to += 1
        except Exception:
            break

    if max_length < len(answer) + 1:
        max_length = len(answer) + 1


print(max_length)