N, K = map(int, input().split())
seq = [0] * N
for i in range(N):
  seq[i] = int(input())

import bisect

LIS = [seq[0]]
for i in range(1, len(seq)):
    if (LIS[-1] - K) <= seq[i] <= (LIS[-1] + K):
        LIS.append(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i]) - 1] = seq[i]
    #print(LIS, i)
print(len(LIS))