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

ans_list = []
append_flag = False
for i in range(N):
    A = int(input())
    now_max = 0
    for j in range(len(ans_list)):
        temp_list = ans_list.pop()
        if abs(temp_list[0] - A) <= K:
            now_max = max(now_max, temp_list[1])
            append_flag = True
        else:
            ans_list.append(temp_list)
    if append_flag:
        ans_list.append([A, now_max + 1])
    else:
        ans_list.append([A, 1])
    append_flag = False

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

print(max_length)