from sys import stdin
def cda(N, x, a, count):
    if N == 0:
        return count
    s = sorted(a)
    if x >= s[0]:
        return cda(N - 1, x - s[0], s[1:], count + 1)
    else:
        return count

def arc027a():
    N, x = (int(s) for s in next(stdin).split(" "))
    a = [int(s) for s in next(stdin).split(" ")]
    print(N, x, a)
    answer = cda(N, x, a, 0)
    print(answer)

def main():
    arc027a()

main()