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

void main()
{
	auto tokens = split(chomp(readln()));
	auto n = to!int(tokens[0]);
	auto x = to!int(tokens[1]);
	int[] a;
	foreach (token; split(chomp(readln())))
	{
		a ~= to!int(token);
	}
	a.sort;
	
	int result;
	foreach (i, e; a)
	{
		if (e <= x)
		{
			x -= e;
		}
		else
		{
			result = i;
		}
	}

	writeln(result);
	stdout.flush();
}