def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    A=[0]*N
    for i in range(N):
        A[i]=int(sys.stdin.readline())

    dp=[0]*(N+1)
    dp[0]=1
    if abs(A[0]-A[1])<=K:
        dp[1]=2
    else:
        dp[1]=1
    
    for i in range(2,N):
        mx=1
        if abs(A[i-2]-A[i])<=K:
            mx=max(mx,dp[i-2]+1)
        if abs(A[i-1]-A[i])<=K:
            mx=max(mx,dp[i-1]+1)
        dp[i]=mx

    print(max(dp))

main()