package main import . "fmt" import . "sort" func main() { var x,n int Scan(&x,&n) w:=make([]int,n) for i:=range w { Scan(&w[i]) } Ints(w) for _,v:=range w { if v > x { break } x-=v n++ } Println(n) }