import bisect
N,K=map(int,input().split())
A=int(input())
LIS = [A-1]
for i in range(N-1):
  A=int(input())
  if abs(A-1-LIS[-1])<=K:
    LIS.append(A-1)
  else:
    LIS[bisect.bisect_left(LIS, A)-1] = A-1

print(len(LIS))