fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let _n: usize = itr.next().unwrap().parse().unwrap(); let k: usize = itr.next().unwrap().parse().unwrap(); let mut p = String::new(); std::io::stdin().read_line(&mut p).ok(); let p: Vec = p.trim().split_whitespace() .map(|x| x.parse().unwrap()).collect(); let mut ans = 0; for i in (0..=400).rev() { let y = p.iter().filter(|&x| x >= &i).count(); if y > k { break; } ans = y; } println!("{}", ans); }