#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using bint = boost::multiprecision::cpp_int;

int main()
{
    int N, x;
    std::cin >> N >> x;
    std::vector<int> a;
    for (int i = 0; i < N; i++) {
        int a_;
        std::cin >> a_;
        a.emplace_back(a_);
    }
    bint max = std::accumulate(a.begin(), a.end(), 0);
    if (max == x) {
        std::cout << N << std::endl;
        return 0;
    }

    std::sort(a.begin(), a.end());
    bint sum = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        sum += a.at(i);
        if (sum > x) {
            break;
        }
        ans = i + 1;
    }
    if (ans == N) {
        ans = N - 1;
    }
    std::cout << ans << std::endl;
    return 0;
}