def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n,x=map(int,input().split())
    a=sorted(map(int,input().split()))
    xx = x
    cnt = 0
    suma = sum(a)
    if suma < x:
        print(n-1)
    elif suma == x:
        print(n)
    else:
        for i in a:
            cnt+=1
            xx-= i
            if xx <=0:
                break
        print(cnt)

if __name__ == '__main__':
    main()
