import java.util.Arrays; import java.util.Scanner; public class No5 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int length = s.nextInt(); int count = s.nextInt(); int[] arr = new int[count]; for (int i = 0; i < count; i++) { arr[i] = s.nextInt(); } Arrays.sort(arr); int sum = 0; for (int i = 0; i < count; i++) { sum += arr[i]; if (sum > length) { System.out.println(i); return; } } System.out.println(count); } }