using System;
using System.Collections.Generic;
using System.Linq;
using console = System.Console;

namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            var p = int.Parse(console.ReadLine().Split()[1]);
          var q = console.ReadLine().Split().Select(i=>int.Parse(i)).OrderBy(i=>i).Select(i=>{p-=i;return p;}).Count(i=>i>=0);
          console.WriteLine(q-(p>0?1:0));
        }
    }
}