using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Int = System.Int64;

class A {
    static Int MaxInt = Pow(10, 10);
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        Int N, X;
        Input(out N, out X);
        Int[] A;
        Input(out A);
        Array.Sort(A);
        int count = 0;
        for(Int i = 0; i < N - 1; i++) {
            if(A[i] <= X) {
                X = X - A[i];
                count++;
            } else {
                break;
            }
        }
        if(A[N - 1] == X) {
            count++;
        }
        Print(count);
        Out.Flush();
    }
    static Int Gcd(Int a, Int b) {
        if(a < b) {
            return Gcd(b, a);
        }
        while(b != 0) {
            Int r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    static Int Lcm(Int a, Int b) {
        return a / Gcd(a, b) * b;
    }
    static Int Pow(Int a, Int b) {
        if(b == 0) {
            return 1;
        } else {
            if(b % 2 == 0) {
                return Pow(a * a, b / 2);
            } else {
                return a * Pow(a, b - 1);
            }
        }
    }
    static Int Log(Int a, Int b) {
        for(Int i = 0; true; i++) {
            if(a < Pow(b, i)) {
                return i - 1;
            }
        }
    }

    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Input<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 13524