import java.util.*; public class Main { public static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { int l = sc.nextInt(); int n = sc.nextInt(); List list = new ArrayList<>(); for (int i = 0; i < n; i++) { list.add(sc.nextInt()); } Collections.sort(list); int sum = 0; int ret = 0; for (Integer i : list) { sum += i; if (sum > l) { break; } ret++; } System.out.println(ret); } }