import java.util.Scanner; import java.util.Arrays; class Block{ public static void main(String args[]){ Scanner s = new Scanner(System.in); int L = s.nextInt(); int N = s.nextInt(); int W[] = new int[N]; for(int i = 0; i < N; i++){ W[i] = s.nextInt(); } Arrays.sort(W); int sum = 0; int j = 0; while(sum <= L){ sum += W[j]; j++; } System.out.println(j-1); } }