#include #include #include int l, n; int w[10001]; int dp[10001]; int main(){ std::cin >> l >> n; for (int i = 0; i < n; i++)std::cin >> w[i]; memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < n; i++){ for (int j = l; j >= 0; j--){ if (dp[j] == -1)continue; if (j + w[i] <= l)dp[j + w[i]] = dp[j] + 1; } } std::cout << *std::max_element(dp, dp + l + 1) << std::endl; return 0; }