import sys


# n = int(sys.stdin.readline().strip())
#
# line = sys.stdin.readline().strip()
# values = list(map(int, line.split()))


def main():
    line = sys.stdin.readline().strip()
    values = list(map(int, line.split()))
    N, x = values[0], values[1]
    line = sys.stdin.readline().strip()
    values = list(map(int, line.split()))
    svalues = sorted(values)
    res = 0
    for i in svalues:
        if i <= x:
            x -= i
            res += 1
        else:
            break
    if x != 0:
        res -= 1
    print(res) if res != -1 else print(0)


if __name__ == '__main__':
    main()
