import sys
input = lambda : sys.stdin.readline().rstrip()

n, k = map(int, input().split(" "))

nums = [int(input()) for i in range(n)]

last_nodes = [n-1]
olast_nodes = []
first = True

while True:
    #print("last_nodes", last_nodes)
    cur_max_depth = 0
    for last_node in last_nodes:
        last_num = nums[last_node]

        node2depth = [None] * n
        node2depth[last_node] = 1
        depth2node = [None] + [[] for i in range(n)] 
        depth2node[1].append((last_node, last_num))
        cur_max_depth = 1

        for node1 in reversed(range(n-2)):
            found = False
            num1 = nums[node1]
            for fdepth in range(cur_max_depth, 0, -1):
                gnodes = depth2node[fdepth]
                for gnode, gnum in gnodes:
                    if abs(gnum-num1) <= k:
                        found = True
                        cur_depth = fdepth+1
                        depth2node[cur_depth].append((node1, num1))
                        cur_max_depth = max(cur_depth, cur_max_depth)
                        break
                if found:
                    break


            if not found:
                if first:
                    olast_nodes.append(node1)

    if first:
        first = False
        out = cur_max_depth
        last_nodes = olast_nodes
    else:
        out = max(cur_max_depth, out)
        break


#print(depth2node)


print(out)