#include #include #include #include #include #define rep(i,n) for(i=0; i> a #define out(a,b) cout << a << b using namespace std; using lint = long long; int main(void){ int i, j, n, m, k, cnt = 0; in(k); in(n); vector x(n); rep(i,n) in(x[i]); bool f=true; while(k>0&&x.size()){ k-=*min_element(x.begin(),x.end()); x.erase(min_element(x.begin(),x.end())); cnt++; if(k==0) f=false; } if(f) cnt--; out(cnt,endl); return 0; }