def main():
    n, x = [int(s) for s in input().split()]
    a = [int(s) for s in input().split()]
    a.sort()
    m = 0

    for i in a:
        if i > x:
            break
        x -= i
        m += 1

    if x != 0:
        m = max(0, m - 1)
    print(m)

main()
