#define NOMINMAX

#include <vector>
#include <iostream>
#include <algorithm>
#include <cstddef>

struct child {
    int a;
    bool b;
    bool operator <(child const& arg) {
        return a < arg.a;
    }
};

int main() {
    auto n = int{};
    auto x = int{};
    std::cin >> n;
    std::cin >> x;
    auto children = std::vector<child>(n);
    for (auto& e : children) {
        std::cin >> e.a;
        e.b = false;
    }

    static auto const is_b = [](child const& a) {
        return a.b;
    };

    std::sort(children.begin(), children.end());
    auto next = [&children]() {
        auto it = std::find_if_not(children.begin(), children.end(), is_b);
        if (it == children.end())
            return;
        it->b = true;
        std::for_each(children.begin(), it, [](child& e) {
            e.b = false;
        });
    };

    auto sum = [&children]() {
        int result = 0;
        for (auto const& e : children) {
            if (e.b)
                result += e.a;
        }
        return result;
    };
    auto count_enabled = [&children]() {
        return std::count_if(
            children.begin(),
            children.end(), [](child const& e) {
                return e.b;
            });
    };

    std::ptrdiff_t min = 0u;
    while (true) {
        next();
        auto const summed = sum();
        auto const counted_enabled = count_enabled();
        if (summed == x) {
            std::cout << counted_enabled << std::endl;
            return 0;
        }
        if (summed <= x)
            min = std::max(min, counted_enabled);
        if (count_enabled() == children.size()) {
            std::cout << std::max(std::ptrdiff_t(0), min - 1) << std::endl;
            return 0;
        }
    }
}
