using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var Nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = Nx[0];
            var x = Nx[1];
            var aList = Console.ReadLine().Split(' ').Select(int.Parse);

            var nokori = x;
            var output = 0;
            foreach (var a in aList.OrderBy(a => a))
            {
                if (nokori < a)
                {
                    break;
                }

                nokori -= a;
                output++;
            }

            if (nokori > 0)
            {
                output = Math.Max(output - 1, 0);
            }

            Console.WriteLine(output);
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}
