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

namespace Atcoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int x = int.Parse(input[1]);
            string[] childs = Console.ReadLine().Split(' ');
            int[] childsInt = new int[childs.Length];
            for (int i = 0; i < childs.Length;i++){
                childsInt[i] = int.Parse(childs[i]);
            }
            Array.Sort(childsInt);
            int num=0;
            for (int i = 0; i < N;i++){
                if(childsInt[i]<=x){
                    num++;
                    x = x - childsInt[i];
                }else{
                    Console.WriteLine(num);
                    return;
                }
            }
            Console.WriteLine(num);
                   
        }
    }
}
