N, K = map(int, input().split())

count = 0

prev = int(input())
min_prev = prev
max_prev = prev

a_list = []
for i in range(N-1):
    a = int(input())
    if count > 0:
        if abs(a-prev) <= K:
            count += 1
            prev = a
            a_list.append(a)
    else:
        if abs(a-min_prev) <= K or abs(a-max_prev) <= K:
            count += 2
            prev = a
        else:
            min_prev = min(a, min_prev)
            max_prev = max(a, max_prev)
        # print(a, count, min_prev, max_prev)
print(count)