import java.util.*; public class No5 { public static void main(String[] arg){ Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int n = sc.nextInt(); int[] w = new int[n]; int i; int count = 0; for (i = 0; i < n; i++){ w[i] += sc.nextInt(); } Arrays.sort(w); for (i = 0; i < n; i++){ l -= w[i]; if (l <= 0){ break; } count++; } System.out.println(count); } }