def solve(N, x, a_list):
    if sum(a_list) == x:
        return N
    sorted(a_list)
    happy_no = 0
    for a in a_list:
        if x < a:
            return happy_no
        happy_no += 1
        x -= a
    return N - 1

if __name__ == '__main__':
    (N, x) = (int(_) for _ in input().split())
    a_ary = [int(a) for a in input().split()]
    print(solve(N, x, a_list))
