#include using namespace std; int main() { int N, M; cin >> N >> M; vector vc(N); for( auto&& x : vc ) { cin >> x; } sort( vc.begin(), vc.end() ); int total{},count{}; for( const auto& x : vc ) { if( total <= M ) { if( total + x <= M ) { count++; } total += x; } } cout << count << endl; return 0; }