N, x = map(int, input().split())
aList = [int(x) for x in input().split()]

# x個配り切る
aList.sort()


score = 0
for a in aList:
    if x >= a:
        x -= a
        score += 1
    else:
        break
if x > 0 and score > 0:
    score -= 1
print(score)