#include #include #include using namespace std; template inline void print_STL(STL c, string ab = ""){ cout << ab << '\n'; for(auto t : c) cout << t << ' '; cout << '\n';} template inline void import_VEC(VEC& c, int n){ typename VEC::value_type tmp; for(int i = 0; i < n; ++i){ cin >> tmp; c.push_back(tmp);} } #define SPRE(x) setprecision(x) // 精度を指定 template using Matrix = vector>; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; vector c; cin >> n >> m; import_VEC(c, n); sort(c.begin(), c.end()); int ans = 0; for(auto t : c) if(m >= t){ m-=t; ans++; } cout << ans << '\n'; ans++; }