import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int n = sc.nextInt(); int min = Integer.MAX_VALUE; int[] dp = new int[m + 1]; for (int i = 0; i < n; i++) { int p = sc.nextInt(); min = Math.min(min, p); for (int j = 0; j <= m - p; j++) { if (j > 0 && dp[j] == 0) { continue; } for (int k = 1; j + k * p <= m; k++) { dp[j + k * p] = Math.max(dp[j + k * p], dp[j] + k); } } } long ans = m / min; for (int i = 2; i < m; i++) { if (isPrime(i)) { ans += dp[m - i]; } } System.out.println(ans); } static boolean isPrime(int x) { for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return false; } } return true; } }