//#include "MyHeader.h" //#include "Algorithm.h" //#include "Bit.h" //#include "UnionFind.h" //#include "NumberTheory.h" //#include "Graph.h" //#include "SegmentTree.h" //#include "Dijkstra.h" //#include "bits/stdc++.h" #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include "boost/variant.hpp" // #include "bits/stdc++.h" using namespace std; #define rep(i, N, M) for(ll i=N, i##_len=(M); ii##_len; --i) #define pb push_back typedef pair pd; typedef long long ll; typedef pair pll; constexpr ll MOD = 1000000007; constexpr ll INF = 1LL << 62; template struct tll_impl { using type = decltype(tuple_cat(tuple(), declval::type>())); }; template<> struct tll_impl<1> { using type = tuple; }; template using tll = typename tll_impl::type; template constexpr ll SZ(T& v) { return static_cast(v.size()); }; template struct vec_t_impl { using type = vector::type>; }; template struct vec_t_impl<1, T> { using type = vector; }; template using vec_t = typename vec_t_impl::type; // check static_assert(is_same, vector>>>::value, ""); // decompose vector into basetype and dimension. template struct vec_dec { static constexpr int dim = 0; using type = T; }; template struct vec_dec> { static constexpr int dim = vec_dec::dim + 1; using type = typename vec_dec::type; }; static_assert(is_same>::type, ll>::value, ""); static_assert(vec_dec>::dim == 3, ""); template vector make_v(size_t a) { return vector(a); } template auto make_v(size_t a, Ts... ts) { return vector(ts...))>(a, make_v(ts...)); } // ex: auto dp = make_v(4,5) => vector> dp(4,vector(5)); // check if T is vector template < typename T > struct is_vector : std::false_type {}; template < typename T > struct is_vector> : std::true_type {}; template typename enable_if::value>::type fill_v(T& t, const V& v) { t = v; } template typename enable_if::value>::type fill_v(T& t, const V& v) { for (auto&& x : t) fill_v(x, v); } // ex: fill_v(dp, INF); typedef vector vll; typedef vector vvll; typedef vector vpll; typedef vector vb; typedef vector vvb; typedef vector vs; template using pq_greater = priority_queue, greater>; #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(), (a).rend() #define perm(c) sort(all(c));for(bool c##perm=1;c##perm;c##perm=next_permutation(all(c))) template void chmin(T & a, T b) { if (a > b) a = b; } template void chmax(T & a, T b) { if (a < b) a = b; } vll seq(ll i, ll j) { vll res(j - i); rep(k, i, j) res[k] = i + k; return res; } constexpr ll POW_(ll n, ll m) { ll res = 1; rep(i, 0, m) { res *= n; } return res; } template constexpr ll POW(ll x, ll n) { if (x == 2) { return (1LL << n) % mod; } if (n == 0)return 1; if (n == 1)return x % mod; if (n % 2 == 0)return POW_(POW(x, n / 2), 2LL) % mod; return ((POW_(POW(x, n / 2), 2LL) % mod) * (x % mod)) % mod; } template<> constexpr ll POW<0>(ll x, ll n) { if (x == 2) { return 1LL << n; } if (n == 0)return 1; if (n == 1)return x; if (n % 2 == 0) return POW_(POW(x, n / 2), 2); return (POW_(POW(x, n / 2), 2)) * x; } template< typename Inputs, typename Functor, typename T = typename Inputs::value_type> void sort_by(Inputs & inputs, Functor f) { std::sort(std::begin(inputs), std::end(inputs), [&f](const T & lhs, const T & rhs) { return f(lhs) < f(rhs); }); } template< typename Inputs, typename Functor, typename T = typename Inputs::value_type> void stable_sort_by(Inputs & inputs, Functor f) { std::stable_sort(std::begin(inputs), std::end(inputs), [&f](const T & lhs, const T & rhs) { return f(lhs) < f(rhs); }); } // ============================ Header ================================= int main() { cin.tie(0); ios::sync_with_stdio(false); ll l, n; cin >> l >> n; vll w(n); rep(i, 0, n)cin >> w[i]; ll N = POW(10, 5) * 2; vll dp(N,-1); dp[0] = 0; rep(i, 0, n) { rrep(j, 0, N) { ll wi = j + w[i]; if (dp[j] != -1 && wi<= l) { dp[wi] = max(dp[wi], dp[j] + 1); } } } cout << *max_element(all(dp))<> T; //rep(test, 1, T + 1) { // [&] { // cout << "Case #" << test << ": " << ok << endl; // }(); //} return 0; }