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):
#     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)]
            return 1
#         memo[(current_value, i)] = 0
#         return memo[(current_value, i)]
        return 0
    
    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)]
        return max(1+sublist_max_length(list_a[i], i+1), sublist_max_length(current_value, i+1))
#     memo[(current_value, i)] = sublist_max_length(current_value, i+1)
#     return memo[(current_value, i)]
    return sublist_max_length(current_value, i+1)


print(sublist_max_length(None, 0))