from itertools import chain
N,K=map(int,input().split())
A=[int(input()) for _ in range(N)]
A_max = max(A)
A_min = min(A)
if A_max - A_min <= K:
    print(N)
    exit()

dp = [[0]*(N) for _ in range(2)] #len
top = [[0]*(N) for _ in range(2)] #top number

dp[0][0] = 0
dp[1][0] = 1
top[0][0] = -1
top[1][0] = A[0]
for i in range(1, N):
    if dp[0][i] < dp[0][i-1]:
        dp[0][i] = dp[0][i-1]
        top[0][i] = top[0][i-1]

    if abs(A[i] - top[0][i-1]) <= K or top[0][i-1] == -1:
        if dp[1][i] < dp[0][i-1] + 1:
            dp[1][i] = dp[0][i-1] + 1
            top[1][i] = A[i]
        # dp[0][i] = max(dp[0][i], dp[0][i-1])
        # dp[1][i] = max(dp[1][i], dp[0][i-1] + 1)

    if dp[0][i] < dp[1][i-1]:
        dp[0][i] = dp[1][i-1]
        top[0][i] = top[1][i-1]

    if abs(A[i] - top[1][i-1]) <= K:
        if dp[1][i] < dp[1][i-1] + 1:
            dp[1][i] = dp[1][i-1] + 1
            top[1][i] = A[i]
        
        # dp[0][i] = max(dp[0][i], dp[1][i-1])
        # dp[1][i] = max(dp[1][i], dp[1][i-1] + 1)
print(max(chain.from_iterable(dp)))