N, K = map(int, input().split())
B = [0]*N
B[0] = 1
A = []
A.append(int(input()))
for i in range(1, N):
    a = int(input())
    A.append(a)
    for j in range(i):
        if abs(A[j]-a) <= K:
            B[i] = max(B[i], B[j]+1)
print(max(B))
