import java.util.*; import java.util.stream.*; import static java.lang.Math.*; public class Main { private void solve() { Scanner sc = new Scanner(System.in); int l = Integer.parseInt(sc.next()); int n = Integer.parseInt(sc.next()); sc.nextLine(); List sorted = Stream.of(sc.nextLine().split(" ")) .map(Integer::valueOf) .sorted() .collect(Collectors.toList()); int[] sums = IntStream.range(0, sorted.size()) .map(i -> sorted.subList(0, i+1) .stream() .reduce(0, (x, y) -> x + y)) .toArray(); System.out.println(abs(Arrays.binarySearch(sums, l) + 1)); } public static void main(String[] args) { new Main().solve(); } }