import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a, b; a = sc.nextInt(); b = sc.nextInt(); int[] c = new int[b]; for (int i = 0; i < b; i++) { c[i] = sc.nextInt(); } Arrays.sort(c); int sum = 0; int count = 0; for (int i = 0; i < b; i++) { if (sum + c[i] < a) { sum += c[i]; count++; } } System.out.println(count); } }