using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nx = Reads();
            var n = nx[0];
            var x = nx[1];
            var a = Reads();
            Array.Sort(a);
            long sum = 0;
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (sum + a[i] <= x)
                {
                    sum += a[i];
                    ans = i + 1;
                }

            }
            Console.WriteLine(sum==x?ans:ans-1);
              
            
           
           
            



            Console.Out.Flush();
        }
    }
}


