import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); int n = Integer.parseInt(br.readLine()); int[] times = new int[n]; for (int i = 0; i < n; i++) { times[i] = Integer.parseInt(br.readLine()); } HashSet[] dp= new HashSet[n]; dp[0] = new HashSet<>(); for (int i = 1; i < (1 << n); i++) { int sum = 0; for (int j = 0; j < n; j++) { if ((i & (1 << j)) == 0) { continue; } sum += times[j]; if (sum > t) { break; } } if (sum <= t) { dp[0].add(i); } } for (int i = 1; i <= n; i++) { if (dp[i - 1].contains((1 << n) - 1)) { System.out.println(i); return; } dp[i] = new HashSet<>(); for (int x : dp[i - 1]) { for (int y : dp[0]) { if ((x & y) != 0) { continue; } if (!dp[i - 1].contains(x | y)) { dp[i].add(x | y); } } } } } }