import std.stdio;
import std.algorithm;
import std.conv;
import std.string;

void main()
{
    auto nx = readln.chomp.split.to!(ulong[]);
    auto n = nx[0];
    auto x = nx[1];
    auto a = readln.chomp.split.to!(ulong[]);
    sort(a);
    int ans = 0;

    foreach(i, e; a) {
        if(e > x)
            break;
        x -= e;
        ans++;
        if(i + 1 == n  && x > 0)
            ans--;
    }

  ans.writeln;
}
