#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    children=[]
    n,x = map(int,input().split())
    children=list(map(int,input().split()))
    sorted_chiledren=sorted(children)
    counter=0
    last=x

    if sum(children) == x:
        print(n)
        exit()
    elif min(children) > x:
        print(0)
        exit()

    for i in sorted_chiledren:
        if i < last:
            last-=i
            counter+=1
        elif i == last:
            counter+=1
            print(counter)
            exit()
        else:
            break
    print(counter-1)

    
if __name__=="__main__":
    main()