using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var N = arr[0];
        var x = arr[1];
        Array.Sort(a);
        var answer = 0;
        for (int i = 0; i < N; i++)
            if (a[i] <= x){
                answer++;
                x -= a[i];}
        if (x > 0) answer--;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}