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

a = sorted(a)

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

print(solve(x))
