#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
sort(a.begin(), a.end());
long long sum = 0;
int ans = 0;
while (ans < n && sum <= x) sum += a[ans++];
if (ans == n && sum == x) printf("%d\n", n);
else printf("%d\n", ans - 1);
}
