import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int x, int[] a) {
    a.sort();
    int ans = 0;
    for (int i = 0; i < a.length; i++) {
        if (x >= a[i]) {
            ans++;
            x -= a[i];

            if (i == a.length - 1) {
                if (x > 0) ans--;
            }
        }
        else break;
    }
    return ans;
}

void main() {
    auto nx = readints;
    int x = nx[1];
    auto a = readints;

    writeln(calc(x, a));
}
