#include using namespace std; template inline bool chmax(T& x, U a) { return x < a && (x = a, 1); } const int MAXM = 10001; bool not_prime[MAXM] = {true, true}; int M, N; int C[20]; int dp[MAXM]; signed main() { for (int i = 2; i * i < MAXM; i++) { if (not_prime[i]) continue; for (int j = i * i; j < MAXM; j += i) { not_prime[j] = true; } } cin >> M >> N; for (int i = 0; i < N; i++) { cin >> C[i]; } memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j + C[i] <= M; j++) { if (dp[j] < 0) continue; chmax(dp[j + C[i]], dp[j] + 1); } } int ret = max_element(dp, dp + MAXM)[0]; for (int i = 0; i <= M; i++) { if (not_prime[i]) continue; if (dp[M - i] < 0) continue; ret += dp[M - i]; } cout << ret << endl; return 0; }