package main import ( "fmt" "sort" ) func resolve(L, N int, W []int) int { sort.Sort(sort.IntSlice(W)) tmp := 0 for i := 0; i < N; i++ { tmp += W[i] if tmp >= L { return i } } return N } func main() { var L int var N int var W []int fmt.Scanf("%d\n", &L) fmt.Scanf("%d\n", &N) for i := 0; i < N; i++ { var w int fmt.Scanf("%d", &w) W = append(W, w) } fmt.Scanf("\n") fmt.Println(resolve(L, N, W)) }