import java.util.Scanner; import java.util.ArrayList; import java.util.List; import java.util.Collections; class Wandbox { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List list = new ArrayList<>(); int l = sc.nextInt(); int n = sc.nextInt(); int cnt = 0; for (int i = 0; i < n; i++) { list.add(sc.nextInt()); } Collections.sort(list); for (int i = 0; l >= 0; i++) { l -= list.get(i); if (l >= 0) { cnt++; } } System.out.println(cnt); } }