import java.util.Scanner object Main extends App { val sc = new Scanner(System.in) val n = sc.nextInt val k = sc.nextInt val pn = Array.fill(n)(sc.nextInt) val t = (0 to pn.max).map(a => pn.count(_ >= a)).filter(_ <= k) println(if (t.isEmpty) 0 else t.max) }