/** * author: TakeruOkuyama * created: 2020-04-09 14:53:46 **/ #include #define rep(i, n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair; const int MOD = 1000000007; int main(){ int L, N; cin >> L >> N; vector W(N); rep(i, N){ cin >> W[i]; } int ans = 0; while(1){ if(*min_element(W.begin(), W.end()) < L){ L = L - *min_element(W.begin(), W.end()); *min_element(W.begin(), W.end()) = 10001; ans ++; }else{ break; } } cout << ans << endl; //rep(i, N){ // cout<