import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int C = sc.nextInt(); int N = sc.nextInt(); int[] a = new int[N]; for(int i = 0; i < N; i++) { a[i] = sc.nextInt(); } // dp[i]はf=iの制約下でのΣxの最小値を表す(解がなければ-1とする) int[] dp = new int[C + 1]; for(int i = 1; i < C + 1; i++) { int min = Integer.MAX_VALUE; for(int j = 0; j < N; j++) { if(a[j] <= i && dp[i - a[j]] != -1) min = Math.min(min, 1 + dp[i - a[j]]); } if(min == Integer.MAX_VALUE) min = -1; dp[i] = min; } System.out.println(dp[C]); } }