using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        string N = s[0];
        int x = int.Parse(s[1]);
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int temp = 0;
        Array.Sort(a);
        if(a.Sum() < x)
        {
            Console.WriteLine(x - 1);
            return;
        }

        for(int i = 0; i < a.Length; i++)
        {
            x -= a[i];

            temp = i;
            if(x < 0)
            {
                break;
            }
            temp++;
        }
        Console.WriteLine(temp);
    }
}
