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) n=0 for _,v:=range w { if v > x { break } x-=v n++ } Println(n) }