#include #include #include using namespace std; typedef long long LL; const LL MOD=1000000007; int main(){ LL N, M; cin >> N >> M; vector box(N); for(int i = 0; i < N; i++){ cin >> box[i]; } sort(box.begin(), box.end()); int ans = 0; for(int i = 0; i < box.size(); i++){ if(M >= box[i]){ M -= box[i]; ans = i+1; } } cout << ans << endl; return 0; }