#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    # num_max = 3 * 10 ** 5
    A = [int(input()) for _ in range(N)]

    seen = [False] * N
    ans = 0
    for i in range(N):
        if seen[i]:
            continue
        last_num = A[i]
        seen[i] = True
        cnt = 1
        for j in range(i + 1, N):
            if abs(last_num - A[j]) <= K:
                last_num = A[j]
                seen[j] = True
                cnt += 1
        ans = max(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()
