n, x = map(int, input().split())
a = [int(x) for x in input().split()]

a = sorted(a)

def solve(x):
    cnt = 0
    if x < a[0]:
        return 0
    for i in range(n):
        if x >= a[i]:
            x -= a[i]
            cnt += 1
    if x == 0:
        return cnt
    else:
        return cnt - 1
    

print(solve(x))
