import java.util.*; import java.io.*; public class Main { static int[][] dp; static int t; static int n; static int[] times; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); t = Integer.parseInt(br.readLine()); n = Integer.parseInt(br.readLine()); times = new int[n]; for (int i = 0; i < n; i++) { times[i] = Integer.parseInt(br.readLine()); } dp = new int[1 << n][t + 1]; int min = dfw((1 << n) - 1, 0); System.out.println(min); } static int dfw(int key, int value) { if (key == 0) { return 0; } if (dp[key][value] != 0) { return dp[key][value]; } int min = Integer.MAX_VALUE / 10; for (int i = 0; i < n; i++) { if ((key & (1 << i)) == 0) { continue; } if (value < times[i]) { min = Math.min(min, dfw(key ^ (1 << i), t - times[i]) + 1); } else { min = Math.min(min, dfw(key ^ (1 << i), value - times[i])); } } dp[key][value] = min; return min; } }