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