from collections import deque
import copy

N, K = list(map(int, input().split()))
A = [0] * N
landmark = [1] * N
for i in range(N):
    A[i] = int(input())

queue = deque()
for i in range(N - 1):
    queue.append([[i], i + 1])
while len(queue) != 0:
    now, ind = queue.popleft()
    # 探索条件
    # print("now", now, ind)
    while True:
        if ind >= N:
            break
        if abs(A[ind] - A[now[-1]]) <= K and landmark[ind] < len(now) + 1:
            queue.appendleft([copy.copy(now), ind + 1])
            now.append(ind)
            queue.appendleft([copy.copy(now), ind + 1])
            landmark[ind] = len(now)
            break
        else:
            ind += 1
print(max(landmark))
