def resolve():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for ai in a:
        if x >= ai:
            x -= ai
            ans += 1
    if x and ans:
        ans -= 1
    print(ans)


if __name__ == "__main__":
    resolve()
