n, x = list(map(int, input().split()))

s = list(map(int,input().rstrip().split()))



s.sort()

sum = 0

cnt = 0

flg = True



for ss in s:

    cnt += 1

    sum += ss



    if(sum > x):

        print((cnt-1))

        flg = False

        break



if(flg):

    if (sum < x):

        print((cnt - 1))

    else:

        print(cnt)





n, x = list(map(int, input().split()))

s = list(map(int,input().rstrip().split()))

s.sort()

list_sum = sum(s)

flg = True

if list_sum < x: # 多すぎ

    print((len(s) - 1))

elif list_sum == x: # ちょうど

    print((len(s)))

else:

    s.reverse()

    c = len(s)

    for ss in s:

        list_sum -= ss

        c -= 1

        if list_sum <= x:

            print(c)

            flg = False

            break



    if(flg):

        print((0))
n, x = list(map(int, input().split()))
s = list(map(int, input().rstrip().split()))
s.sort()
sum = 0
cnt = 0
flg = True
for ss in s:
    cnt += 1
    sum += ss
    if sum > x:
        print((cnt - 1))
        flg = False
        break
if flg:
    if sum < x:
        print((cnt - 1))
    else:
        print(cnt)

n, x = list(map(int, input().split()))
s = list(map(int, input().rstrip().split()))
s.sort()
list_sum = sum(s)
flg = True
if list_sum < x:  # 多すぎ
    print((len(s) - 1))
elif list_sum == x:  # ちょうど
    print((len(s)))
else:
    s.reverse()
    c = len(s)
    for ss in s:
        list_sum -= ss
        c -= 1
        if list_sum <= x:
            print(c)
            flg = False
            break
    if flg:
        print((0))

-sum = 0 -cnt = 0 +list_sum = sum(s) -for ss in s: -    cnt += 1 -    sum += ss -    if sum > x: -        print((cnt - 1)) -        flg = False -        break -if flg: -    if sum < x: -        print((cnt - 1)) -    else: -        print(cnt) +if list_sum < x:  # 多すぎ +    print((len(s) - 1)) +elif list_sum == x:  # ちょうど +    print((len(s))) +else: +    s.reverse() +    c = len(s) +    for ss in s: +        list_sum -= ss +        c -= 1 +        if list_sum <= x: +            print(c) +            flg = False +            break +    if flg: +        print((0))