#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { int L,N; cin >> L >> N; vector W(N); for ( int i = 0; i < N; i++ ) { cin >> W[i]; } vector dp(L+1, 0); for ( int i = 0; i < N; i++ ) { for ( int j = 1; j <= L; j++ ) { if ( j >= W[i] ) { dp[ j - W[i] ] = max( dp[j]+1, dp[ j - W[i] ] ); } } } int ans = 0; for ( int i = 0; i <= L; i++ ) { ans = max( ans, dp[i] ); } cout << ans << endl; return 0; }