a = input().split()
a = [int(i) for i in a]
b = input().split()
b = [int(i) for i in b]
b = sorted(b)
output = 0
ok = False
if a[1] < b[0]:
     print (0)
     ok = True

for i in range(len(b) - 1):
    if a[1] - b[i] > 0:
        a[1] += -b[i]
        output += 1
        if a[1] - b[-1] > 0:
            pass
        elif a[1] - b[-1] < 0:
            output -= 1
        else:
            output += 1
    elif(a[1] - b[i] == 0):
        output += 1
        break
    else:
        output -= 1
        break

if ok == False:
     print(output)