N, K = map(int, input().split())
a = int(input())
candidate = [(a, 1)]

for _ in range(N-1):
    a = int(input())
    available = set((prev, length) for prev, length in candidate if abs(prev-a) <= K)
    if not available:
        candidate.append((a, 1))
    else:
        longest = prev, length = max(available, key=lambda t: t[1])
        candidate = [c for c in candidate if c not in available]
        candidate.append((a, length+1))

_, longest_length = max(candidate, key=lambda t: t[1])
print(longest_length)
