import java.util.*; import java.io.*; public class Main { static int[] values; static int[][] dp; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int c = sc.nextInt(); int n = sc.nextInt(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } int[] dp = new int[c + 1]; Arrays.fill(dp, Integer.MAX_VALUE); dp[0] = 0; for (int i = 0; i <= c; i++) { for (int j = 0; j < n; j++) { if (i >= values[j] && dp[i - values[j]] != Integer.MAX_VALUE) { dp[i] = Math.min(dp[i], dp[i - values[j]] + 1); } } } if (dp[c] == Integer.MAX_VALUE) { System.out.println(-1); } else { System.out.println(dp[c]); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }