n,k = map(int,input().split()) P = list(map(int,input().split())) ans = 0 for i in range(k+1): cnt = 0 for j in range(n): if P[j] >= i: cnt += 1 if cnt <= k: ans = max(ans,cnt) print(ans)