import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int L=Integer.parseInt(sc.next()); int N = Integer.parseInt(sc.next()); int[] block=new int[N]; for (int i = 0; i < N; i++) { block[i] = Integer.parseInt(sc.next()); } Arrays.sort(block); int length=0; int count=0; do{ length+=block[count]; count++; }while(L>=length); System.out.println(count-1); } }