import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class No005 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); int L = Integer.parseInt(br.readLine()); int N = Integer.parseInt(br.readLine()); String[] WStrArray = br.readLine().split(" "); int[] W = new int[N]; for (int i = 0; i < N; i++) { W[i] = Integer.parseInt(WStrArray[i]); } Arrays.sort(W); int count = 0; for (int i = 0; i < N; i++) { L = L - W[i]; if (L <= 0) { break; } count++; } System.out.println(count); } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } }