n,k = map(int,input().split()) p = list(map(int,input().split())) for b in range(410): cnt = sum([x>=b for x in p]) if cnt <= k: print(cnt) exit(0)