n,k=map(int,input().split()) A=list(map(int,input().split())) A.append(0) start=0 end=n+1 pok=1 for q in range(n): if A[q]>A[q+1]: start+=pok pok=1 elif A[q]=k or end<=k: del A[n] del A[q] print(*A) exit()