import java.util.Scanner; import java.util.Arrays; public class Main5{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int L = scan.nextInt(), N = scan.nextInt(), W[] = new int[10001]; for(int i = 0; i < N; i++) W[i] = scan.nextInt(); Arrays.sort(W, 0, N); int i = 0; do{ L -= W[i]; i++; }while(L - W[i] >= 0 && W[i] != 0); System.out.println(i); } }