import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)


@lru_cache(None)
def dp(i, prev):
    if i == N:
        return 0
    else:
        if prev is None or abs(A[i] - prev) <= K:
            return max(dp(i + 1, prev), dp(i + 1, A[i]) + 1)
        else:
            return dp(i + 1, prev)

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
print(dp(0, None))
