package main import ( "bufio" "fmt" "os" "sort" "strconv" ) func main() { var sc = bufio.NewScanner(os.Stdin) sc.Scan(); l, _ := strconv.Atoi(sc.Text()) sc.Scan(); n, _ := strconv.Atoi(sc.Text()) sc.Split(bufio.ScanWords) ws := make([]int, n) for i := 0; i < n; i++ { sc.Scan(); w, _ := strconv.Atoi(sc.Text()) ws[i] = w } sort.Ints(ws) ans := 0 for _, w := range ws { if nl := l - w; nl >= 0 { l = nl ans += 1 } } fmt.Println(ans) }