#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+14;
int a[maxn];
void solve(){
int n, s;
cin >> n >> s;
for (int i = 1; i <= n; i++){
cin >> a[i];
}
sort(a + 1, a + 1 + n);
int cnt = 0;
for (int i = 1; i <= n; i++){
if (s < a[i]) break;
s += a[i];
cnt++;
}
cout << cnt ;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuPTFlNisxNDsKaW50IGFbbWF4bl07CnZvaWQgc29sdmUoKXsKCWludCBuLCBzOwoJY2luID4+IG4gPj4gczsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CgkJY2luID4+IGFbaV07Cgl9CgkKCXNvcnQoYSArIDEsIGEgKyAxICsgbik7CglpbnQgY250ID0gMDsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CgkJaWYgKHMgPCBhW2ldKSBicmVhazsKCQlzICs9IGFbaV07CgkJY250Kys7Cgl9CgkKCWNvdXQgPDwgY250IDsKfQppbnQgbWFpbigpewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKCWNpbi50aWUoMCk7ICAgIGNvdXQudGllKDApOwoJc29sdmUoKTsKCXJldHVybiAwOwp9Cg==