from heapq import heappush, heappop
from collections import defaultdict


def update(heap, a, mode=1):
    while heap and abs(a - heap[0][0]) <= K:
        prev, length = heappop(heap)
        dp[a * mode] = max(dp[a * mode], length + 1)
    for key, value in dp.items():
        heappush(heap, (key * mode, value))


N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
dp = defaultdict(int)
bigger = [(-A[0], -1)]
smaller = [(A[0], 1)]
for a in A[1:]:
    update(bigger, -a, -1)
    update(smaller, a)
print(max(dp.values()))