using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;

class Program
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x)).ToArray();
        var n = l[0]; var x = l[1];
        var al = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x))
            .OrderBy(x => x).ToArray();
        var sum = 0L;
        var ans = 0L;
        for (var i = 0L; n > i; i++)
        {
            sum += al[i];
            if (sum > x)
            {
                sum -= al[i];
                break;
            }
            ans++;
        }
        if (x > sum)
        {
            ans--;
        }
        Console.WriteLine(ans);
    }
}