package main import "fmt" import "sort" func main() { var l, n int var w []int fmt.Scanf("%v", &l) fmt.Scanf("%v", &n) w = make([]int, n) for i := 0; i < n; i++ { _, err := fmt.Scan(&w[i]) if err != nil { } } sort.Ints(w) count := 0 sum := 0 for i := 0; i < len(w); i++ { sum = sum + w[i] if sum > l { break } count = count + 1 } fmt.Printf("%d\n", count) }