def main():
    n, k = map(int, input().split())
    A = [int(input()) for _ in range(n)]

    dp = [1] * n
    for i in range(1, n):
        cnt = 0
        for j in range(i):
            if abs(A[i] - A[j]) <= k:
                cnt = max(cnt, dp[j] + 1)
        dp[i] = cnt
    print(dp[-1])
    return


if __name__ == '__main__':
    main()
