using namespace std; #include void _main();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<inline bool chmax(ll&a,ll b){if(ainline bool chmin(ll& a,ll b){if(a>b){a=b;return 1;}return 0;} #define rep1(a) for(int i = 0; i < (a); i++) #define rep2(i, a) for(int i = 0; i < (a); i++) #define rep3(i, a, b) for(int i = (a); i < (b); i++) #define rep4(i, a, b, c) for(int i = (a); i < (b); i += (c)) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define ALL(x) std::begin(x),std::end(x) #define rALL(x) std::rbegin(x),std::rend(x) #define INF ((1LL<<62)-(1LL<<31)) #define bit(x,i) (((x)>>(i))&1) #define fi first #define se second #define pb push_back #define Endl endl #define spa " " #define YesNo(x) cout<<(x?"Yes":"No")< inline void scan(Head&head,Tail&... tail){std::cin>>head;scan(tail...);} #define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__) #define STR(...) string __VA_ARGS__;scan(__VA_ARGS__) //vectorのcin template std::istream &operator>>(std::istream&is,std::vector&v){for(T &in:v){is>>in;}return is;} //vectorのcout template std::ostream &operator<<(std::ostream&os,const std::vector&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;} //x,y,x,yを渡すとldで距離を返す long double my_distance(long double xi,long double yi,long double xj,long double yj){return sqrt(abs((xi-xj)*(xi-xj))+abs((yi-yj)*(yi-yj)));} //可変長引数のprint関数 void print(){cout << '\n';} template void print(const T& a, const Ts&... b){cout << a;(cout << ... << (cout << ' ', b));cout << '\n';} //可変長引数のmin template constexpr auto min(T... a){return min(initializer_list>{a...});} //可変長引数のmax template constexpr auto max(T... a){return max(initializer_list>{a...});} templateinline bool chmax(T&a,U b){if(ainline bool chmin(T&a,U b){if(a>b){a=b;return 1;}return 0;} void solve(); void _main(){ int testcase = 1; // cin >> testcase; for(;testcase--;){ solve(); } } void solve(){ LL(l); LL(n); vectorw(n);cin >> w; sort(ALL(w)); ll now{}; rep(i,n){ now+=w[i]; if(now>l){ O(i); exit(0); } } O(n); }