int main() {
    int N, x;

    std::cin >> N >> x;

    std::vector<int> a(N);
    
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    int num = 0;
    for (auto val : a) {
        x = x - val;
        if (x < 0) {
            break;
        }
        num++;
    }

    std::cout << num << std::endl;
}
