if __name__ == "__main__":
    N,x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    A = 0

    a.sort()
    while x >= 0:
        try:
            if a[-1] < x:
                x -= a.pop(-1)
                A += 1
        except:
            break

    if x != 0:
        A -= 1
    print(A)