import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Yuki_678 { public Yuki_678() { Scanner scanner = new Scanner(System.in); int A = scanner.nextInt(); int N = scanner.nextInt(); int[] data = new int[N]; for (int i = 0; i < N; i++) { data[i] = scanner.nextInt(); } int[] dp = new int[100000 + 1]; dp[0] = 0; for (int i = 0; i <= A; i++) { for (int j = 0; j < N; j++) { int k = i - data[j]; if (k >= 0) { dp[i] = Math.min(dp[i], dp[k] + 1); } } } if (dp[A] == 0) { System.out.println(-1); } else { System.out.println(dp[A]); } } public static void main(String[] args) { Yuki_678 hoge = new Yuki_678(); } }