import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

alias lread = () => readln.chomp.to!long;
alias aryread = () => readln.split.to!(long[]);

void main()
{
    auto nx = aryread();
    long N = nx[0];
    long x = nx[1];
    auto a = aryread();
    a.sort();
    foreach (i; 0 .. N)
    {
        if (x < a[i])
        {
            writeln(i);
            return;
        }
        else
        {
            x -= a[i];
        }
    }
    if (x == 0)
    {
        writeln(N);
    }
    else
    {
        writeln(N - 1);
    }
}
