# https://qiita.com/takayg1/items/7008e4c9584e42ae13c7

from collections import deque

N, K = (int(i) for i in input().split())

graph = [deque([]) for _ in range(N + 1)]

A = []
for _ in range(N):
    a = int(input())
    A.append(a)

for i, a in enumerate(A):
    j = i + 1
    while j < N :
        if abs(a - A[j]) <= K:
            graph[i].append(j)
            break
        j += 1

longest_time = [-1] * (N + 1) 

# 深さ優先探索
def dfs(v):
    if longest_time[v] < 0:
        longest_time[v] = 1
    stack = [v]
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if longest_time[w] <= longest_time[v]:
                longest_time[w] = longest_time[v] + 1
                stack.append(w) 
        else:
            stack.pop()          

# 孤立している頂点対策
for i in range(N):
    if longest_time[i + 1] < 0:
        dfs(i + 1)

print(max(longest_time))