import java.util.*; public class Main { public static void main(String[] args) { int o,p,q; int a = 0, b = 0; Scanner sc = new Scanner(System.in); // int[] test = new int[100000]; // String str = sc.next(); int s = Integer.parseInt(sc.next()); int t = Integer.parseInt(sc.next()); int[] test2 = new int[t]; // int u = Integer.parseInt(sc.next()); /* for(int i = 0; i < str.length() ; i++ ){ o = Integer.valueOf(s).intValue(); b += o; } System.out.println(b); */ int d = 0; while(true){ if(d==t)break; int v = Integer.parseInt(sc.next()); test2[d] = v ; d++; } Arrays.sort(test2); d=0; while(true){ if(s<=a)break; a += test2[d]; d++; } System.out.println(d); System.out.println(); } }