N,x = map(int,input().split())
a_list = sorted(list(map(int,input().split())))
if sum(a_list) < x:
    print(N-1)
    exit()
if a_list[0] > x:
    print(0)
    exit()
for i in range(N+1):
    if sum(a_list[:i]) >= x:
        print(i)
        exit()
