fn getline() -> String{ let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok(); ret } fn getvec(string: String) -> Vec { string.trim().split_whitespace() .map(|s| s.parse().unwrap()) .collect() } fn bubblesort(v: &Vec) -> Vec { let mut dst = v.to_owned(); for i in 0..dst.len() { for j in i..dst.len() { if dst[i] > dst[j] { dst.swap(i, j) } } } dst } fn solve(v: &Vec, l: i32) -> usize { let sorted = bubblesort(v); let mut acc = 0; for (i, a) in sorted.into_iter().enumerate() { acc += a; if acc > l { return i } else if acc == l { return i+1 } } v.len() } fn main() { let l:i32 = getline().trim().parse().unwrap(); let _:i32 = getline().trim().parse().unwrap(); println!("{}", solve(&getvec(getline()), l)) }