#include #define rep(i,a,n) for (int i = a;i < n;i++) #define per(i,n,a) for (int i = n-1;i >= a;i--) using namespace std; int main() { int n,m; cin >> n >> m; vector c(n); rep(i,0,n){ cin >> c[i]; } sort(c.begin(),c.end()); int ans = 0; rep(i,0,n){ m -= c[i]; if(m >= 0) ans++; } cout << ans << endl; }