import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int n = sc.nextInt(); int[] N = new int[n]; int ans = 0; for(int i = 0; i < n; i++){ N[i] = sc.nextInt(); } Arrays.sort(N); int i = 0; while(l >= ans){ ans += N[i]; i++; if(i == n && ans <= l){ i++; break; }else if(i == n){ break; } } System.out.println(i - 1); } }