# -*- coding: utf-8 -*-
N, K = map(int, input().split())

ans_list = []
append_flag = False
for i in range(N):
    A = int(input())
    for j in range(len(ans_list)):
        if abs(ans_list[j][-1] - A) <= K:
            ans_list[j].append(A)
            append_flag = True
    if not append_flag:
        ans_list.append([A])
    append_flag = False

max_length = 0
for i in range(len(ans_list)):
    max_length = max(len(ans_list[i]), max_length)

print(max_length)