import java.util.Arrays; import java.util.Scanner; public class Yuki1 { public static void main(String argas[]) { Scanner scan = new Scanner(System.in); // 箱の幅 int box = scan.nextInt(); //int box = 16; // ブロックの数 int blockCount = scan.nextInt(); //int blockCount = 3; int num = scan.nextInt(); int blockWidth[] = new int [num]; //int blockWidth[] = {10,5,7}; /* for (int i = 0; i <= num; i++) { blockWidth[i] = scan.nextInt(); }*/ Arrays.sort(blockWidth); /* for(int i = 0; i< 3; i++){ System.out.println(blockWidth[i]); } */ int boxWidthAll = 0; int boxWidthAllCount = 0; while(box>boxWidthAll){ boxWidthAll +=blockWidth[boxWidthAllCount]; if(box>boxWidthAll) { boxWidthAllCount++; } } System.out.println(boxWidthAllCount); } }