N, K = map(int, input().split()) X = list(map(int, input().split())) dp = [0] j = 0 for i in range(N): while j < i and X[i] - X[j] >= K: j += 1 dp.append(max(dp[i], dp[j] + 1)) print(dp[N])