line = input().rstrip().split(" ")
num = int(line[0])
diffirence = int(line[1])

digitline = []
for i in range(num):
        digitline.append(int(input().rstrip()))

answer = 0
for j in range(num // 2):
    lastdigit = digitline[j]
    answerlist = [lastdigit]
    for k in range(num - j):
        digit = digitline[j + k]
        if abs(digit - lastdigit) <= diffirence:
            answerlist.append(digit)
            lastdigit = digit
    if answer <= len(answerlist):
        answer = len(answerlist)

print(answer - 1)