def main():
    N,x=[int(i) for i in input().split()]
    a=input().split()
    k=0
    while True:
        if x>=int(min(a)):
            if len(a)==1:
                if x>int(min(a)):
                    k-=1
            x=x-int(min(a))
            a.remove(min(a))
            k+=1

            if len(a)==0:
                break
        else:
            break
    print(k)
main()
