import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int haba = sc.nextInt(),num = sc.nextInt(); ArrayList list = new ArrayList(); for(int i = 0 ; i < num ; i++)list.add(sc.nextInt()); Collections.sort(list); int count = 0 , kosu = 0; while(count < haba) { count += list.get(kosu); kosu++; } System.out.println(kosu - 1); } }