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

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


def subilst_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 1
        memo[(current_value, i)] = 0
        return 0
    
    if (current_value is None) or (abs(current_value - list_a[i]) <= k):
        # iの値をsublistに含めるor含めない
        memo[(current_value, i)] = max(1+subilst_max_length(list_a[i], i+1), subilst_max_length(current_value, i+1))
        return memo[(current_value, i)]
    memo[(current_value, i)] = subilst_max_length(current_value, i+1)
    return memo[(current_value, i)]
  
print(subilst_max_length(None, 0))