import java.util.Arrays; import java.util.Scanner; public class Yukicoder { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int n = sc.nextInt(); int[] arrays = new int[n]; for (int i = 0; i < n; i++) { arrays[i] = sc.nextInt(); } Arrays.sort(arrays); int sum = 0; int count = 0; for (int i = 0; i < n; i++) { sum += arrays[i]; if (sum > l) { break; } else { count++; } } System.out.println(count); sc.close(); } }