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

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

    foreach(e; a) {
        x -= e;
        if(x >= 0)
            ans++;
        else
            break;
    }

    if (x > 0)
        ans--;

    ans.writeln;
}
