def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))

    A_sorted = sorted(A)

    res = 0

    for kids in A_sorted:
        if x - kids >= 0:
            x = x - kids
            res += 1
    
    print(res)

if __name__ == '__main__':
    main()