
def recursion(arr, idx, value, criteria, counta):
    if idx >= len(arr):
        return counta
    # print(idx, value, arr[idx], 'criteria', criteria)
    if arr[idx] - value <= criteria:
        result_skip =  recursion(arr, idx + 1, value, criteria, counta)
        result_process = recursion(arr, idx + 1, arr[idx], criteria, counta+1)
        if result_skip >= result_process:
            return result_skip
        return result_process
    return recursion(arr, idx + 1, value, criteria, counta)
    

n, k = [int(i) for i in input().split()]
arr = [int(input()) for i in range(n)]
diff_arr = []
tmp = 0

result = max([recursion(arr, idx + 1, item, k, 0) for idx, item in enumerate(arr)])
print(result)
    
