import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int l = scan.nextInt(); int n = scan.nextInt(); int[] w = new int[n]; for (int i = 0; i < n; i++) { w[i] = scan.nextInt(); } Arrays.sort(w); int cnt = 0; for (int v : w) { l -= v; if (l < 0) { break; } else { cnt++; } } System.out.println(cnt); scan.close(); } }