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

    candy = 0
    for n in range(n):
        candy += an[n]
        if (candy > x):
            print(n)
            return

    print(n)


if __name__ == '__main__':
    main()
	