#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;
int sum = 0;
for (int i = 1; i <= n; i++){
sum += a[i];
if (sum > s) break;
cnt ++;
}
cout << cnt ;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuPTFlNisxNDsKaW50IGFbbWF4bl07CnZvaWQgc29sdmUoKXsKCWludCBuLCBzOwoJY2luID4+IG4gPj4gczsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CgkJY2luID4+IGFbaV07Cgl9CgkKCXNvcnQoYSArIDEsIGEgKyAxICsgbik7CglpbnQgY250ID0gMDsKCWludCBzdW0gPSAwOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKXsKCQlzdW0gKz0gYVtpXTsKCQlpZiAoc3VtID4gcykgYnJlYWs7CgkJY250ICsrOwoJfQoJCgljb3V0IDw8IGNudCA7Cn0KaW50IG1haW4oKXsKCWlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CgljaW4udGllKDApOyAgICBjb3V0LnRpZSgwKTsKCXNvbHZlKCk7CglyZXR1cm4gMDsKfQo=