import java.util.*; class Main { static int INF = 2 << 27; 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(); } int[] dp = new int[c+1]; Arrays.fill(dp, INF); dp[0] = 0; for(int i = 0; i < n; i++) { for(int j = 0; j <= c; j++) { if(dp[j] == INF) { continue; } if(j + a[i] > c) { break; } dp[j + a[i]] = Math.min((dp[j] + 1),dp[j + a[i]]); } } int min = dp[c]; if(min == INF) { min = -1; } System.out.println(min); } }