N, K = map(int, input().split())
A = [-1 for i in range(N)]
dp = [-1 for i in range(N)]

for i in range(N):
    A[i] = int(input())

def solve(p,a):
    global N,K,A,dp
    ans = 0
    if dp[p] != -1:
        ans = dp[p]
    elif p==N-1:
        ans = 0
    elif abs(A[p]-a)>K:
        ans = solve(p+1,a)
    else:
        ans = max(solve(p+1,A[p])+1, solve(p+1,a))

    dp[p] = ans
    return ans

solve(0,0)
print(dp[0]+1)