import sys
sys.setrecursionlimit(3000000) 

n, k = map(lambda x: int(x), input().split())

list_a = []
for _ in range(n):
     list_a.append(int(input()))
        
memo = dict()

# i番目以降の要素からなるsublistの長さとして最長のものの長さを返す
def sublist_max_length(current_value, i):
    print(current_value, i)
    if (current_value, i) in memo.keys():
        return memo[(current_value, i)]
    if i == n-1:
        if (current_value is None) or (abs(current_value - list_a[i]) <= k):
            memo[(current_value, i)] = 1
            return memo[(current_value, i)]
        memo[(current_value, i)] = 0
        return memo[(current_value, i)]
    
    if (current_value is None) or (abs(current_value - list_a[i]) <= k):
        # iの値をsublistに含めるor含めない
        memo[(current_value, i)] = max(1+sublist_max_length(list_a[i], i+1), sublist_max_length(current_value, i+1))
        return memo[(current_value, i)]
    memo[(current_value, i)] = sublist_max_length(current_value, i+1)
    return memo[(current_value, i)]

print(sublist_max_length(None, 0))