import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] a) { Scanner s=new Scanner(System.in); int L=s.nextInt(),N=s.nextInt(),i=0,Z=0; int[] B=new int[N]; while(s.hasNext())B[i++]=s.nextInt(); Arrays.sort(B); for(i=0;L>(Z+=B[i++]);); System.out.println(i-(Z>L?1:0)); } }