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

class Program
{
	public static int Main(string[] args)
	{
        int ans=0;
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int x = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        int[] a = new int[N];
        for (int i = 0; i < N;i++){
            a[i] = int.Parse(str[i]);
        }
        Array.Sort(a);
        for (int i = 0; i < N;i++){
            if(x-a[i]>=0){
                x -= a[i];
                ans++;
            }
            else{
                break;
            }
        }
        if (x > 0 && ans>0) ans--;
        int answer = 0;

        Console.WriteLine(ans);

        return 0;
	}
}
