let L = Int(readLine()!)! let N = Int(readLine()!)! var W = readLine()!.split(separator: " ").map{Int($0)!} W.sort() var sum :Int = 0 var count :Int = 0 while sum < L{ sum = sum + W[count] count = count + 1 } print(count - 1)