use std::io; use std::io::{Stdin, BufRead}; struct Input { l: u32, n: u32, w: Vec, } fn main() { let mut stdin = io::stdin(); let input = read_input(&mut stdin); let mut w = input.w; w.sort(); let mut count = 0; let mut sum = 0; for e in w { sum += e; if input.l < sum { break; } count += 1; } println!("{}", count); } fn read_input(stdin: &mut Stdin) -> Input { let l: u32 = read_single(); let n: u32 = read_single(); let mut w: Vec = read_vec(); Input { l, n, w } } fn read_single() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read_single::().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() }