import java.util.Arrays; import java.util.Scanner; public class Main { private int n; private int l; private int[] w; Main(){ this.w = new int[10010]; } public void setN(int n){ this.n = n; } public void setL(int l){ this.l = l; } public void setW(int i,int num){ this.w[i] = num; } public int run(){ int ans = 0; Arrays.sort(w, 0, this.n); int last = this.l; for(int i = 0;i < this.n;i++){ if(last - w[i] >= 0){ last -= w[i]; ans++; } } return ans; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); Main m = new Main(); int l = sc.nextInt(); int n = sc.nextInt(); int w; m.setN(n); m.setL(l); for(int i = 0;i < n;i++){ w = sc.nextInt(); m.setW(i, w); } System.out.println(m.run()); } }