import java.util.Arrays; import java.util.Scanner; public class No05 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int length = sc.nextInt(); int cntBlk = sc.nextInt(); int[] widthOfBlk = new int[cntBlk]; for(int i = 0; i < widthOfBlk.length; i++){ widthOfBlk[i] = sc.nextInt(); } System.out.println(cnt(widthOfBlk, length)); } static int cnt(int[] w, int l){ int cnt = 0; Arrays.sort(w); for(int w1 : w){ int tmp = l - w1; if(tmp >= 0){ l = tmp; cnt++; } } return cnt; } }