peterverebics/CodeNet_Python_118 huggingface dataset:
N,x = map(int,input().split())
a = list(map(int,input().split()))
A = sorted(a)

cont = 0
if x > sum(A):
    print(N-1)
else:
    for i in range(N):
        if x >= A[i]:
            x -= A[i]
            cont += 1
    print(cont)
N, x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

ans = 0
for i in range(N):
    x -= a[i]
    if i == N-1:
        if x == 0:
            ans += 1
    elif x >= 0:
        ans += 1
print(ans)
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
c,i=0,0
while(i<n and x>0):
  if a[i]<=x:
    x-=a[i]
    c+=1
  else:
    break
  if i==n-1 and x!=0:
    c-=1
  i+=1
print(c)
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0
for i in a:
    if x >= i:
        cnt += 1
        x -= i
    else:
        break
else:
    if x > 0:
        cnt -= 1
print(cnt)
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
i = 0
while x >= a[i]:
    if i == n-1:
        if a[i] == x:
            ans+=1
            break
        else:
            break
    x -= a[i]        
    i += 1
    ans += 1
print(ans)
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))

cnt = 0
for i in range(N):
  if i == N - 1:
    if x == A[i]:
      cnt += 1
      x -= A[i]
  else:
    if x >= A[i]:
      cnt += 1
      x -= A[i]

print(cnt)
N,x = map(int,input().split())
A = sorted(map(int,input().split()))

S =[0]+[0 for i in range(N)]
for i in range(N):
  S[i+1]=S[i]+A[i]
  #print(S)
  if S[i+1]>x:
    print(i)
    exit()
if S[-1]==x:
  print(N)
else:
  print(N-1)
n, x = map(int, input().split())
aList = list(map(int, input().split()))
aList.sort()
sums = 0
i = 0
while sums < x and i < n:
    sums += aList[i]
    i += 1
i -= 1
if sums == x:
    i += 1
print(i)
n, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(n + 1):
    if sum(A[:i]) > x:
        print(i - 1)
        exit()
    elif sum(A[:i]) == x:
        print(i)
        exit()
print(n - 1)
n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
now = x
for i in range(n):
    now -= a[i]
    if now < 0:
        print(i)
        exit()
    elif now == 0:
        print(i+1)
        exit()
print(n-1)
N,x=map(int,input().split(' '))
A=sorted(list(map(int,input().split(' '))))
ans = 0
for i in A:
    if x >= i:
        ans += 1
        x -=i
    else:
        break
if x > 0 and ans==N:
    print(N-1)
else:
    print(ans)
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if x < min(A):
    print(cnt)
    break
  elif i == N-1 and x-A[0] > 0:
    print(N-1)
    break
  elif i == N-1 and x-A[0] == 0:
    print(N)
    break
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans,cnt=[0,0]
for i in range(n):
    cnt+=a[i]
    if cnt>x: break
    ans+=1
    if i==n-1 and cnt!=x: ans-=1
print(ans)
n, m = map(int, input().split())
a = sorted(list(map(int,input().split())))
ans = 0
for i in a:
    if m - i < 0:
        print(ans)
        exit()
    m -= i
    ans += 1
if m > 0:
    print(ans-1)
else:
    print(ans)
n,x = map(int,input().split())
a = sorted([int(x) for x in input().split()])

ans = 0
for i in range(n):
    if x >= a[i] and i != n-1:
        x -= a[i]
        ans += 1
    elif i == n-1:
        if x == a[i]:
            ans += 1

print(ans)
N , X = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
a = 0
for i in range(N):
  a += A[i]
  if a > X:
    break
if i == N - 1:
  if a == X:
    print(i + 1)
  else:
    print(i)
if i < N - 1:
  print(i)
n, x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if sum(a) < x:
    print(n-1)
    exit()
    
elif sum(a) == x:
    print(n)
    exit()
    
else:
    a = sorted(a)
    for i in range(n):
        ans += a[i]
        if ans > x:
            print(i)
            exit()
n, x = map(int, input().split())
s = list(map(int, input().split()))

s.sort()
cnt = 0

for i in range(n):
    if x >= s[i]: 
        x -= s[i]
        cnt += 1
    else:
        x = 0
        break

if x > 0:
    cnt -= 1

print(cnt)
N, x = map(int, input().split())
A = map(int, input().split())
#A = sorted(A, reverse=True)
A = sorted(A)

tmp = 0
count = 0
for i, a in enumerate(A):
    if tmp + a > x:
        break
    if (i == len(A) -1) and tmp + a < x:
        break
    tmp += a
    count += 1

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

Slist = sorted(a)
cnt = 0
Sum = 0

if x > sum(Slist):
  print(n-1)
  exit()
  
for i in range(n):
  Sum += Slist[i]
  if x>=Sum:
    cnt +=1
  else:
    break
print(cnt)
n,x = map(int,input().split())
l = sorted(list(map(int,input().split())))

ans = 0
for i in l:
    if i <= x:
        x -= i
        ans += 1
if ans == n and x > 0:
    print(ans-1)
else:
    print(ans)
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0
for i in range(len(a)):
    if i < len(a) - 1 and a[i] <= x:
        count += 1
        x -= a[i]
    elif i == len(a) - 1 and a[i] == x:
        count += 1
    else:
        break
print(count)
# -*- coding: utf-8 -*-

N,x = map(int, input().split())
a = list(map(int, input().split()))

a_sorted = sorted(a)

num = 0
reminder = x
for i in range(N):
    reminder -= a_sorted[i]
    if reminder>=0:
       num += 1
    else:
        break

if reminder>0:
    num -= 1
    
print(num)
n,x=map(int,input().split())
a=sorted([int(i)for i in input().split()])
res=0
if sum(a)==x:
    res=n
else:
    for i in range(n):
        if sum(a[:i])<=x:res=i
print(max(0,res))
n,x=map(int,input().split())
a=[0]*n
a=list(map(int,input().split()))
a=sorted(a)
num=0
ans=0
al=x
for i in range(n):
  num+=a[i]
  al=al-a[i]
  if (num>x):
    break
  if (i==n-1 and num<x):
    break
  ans+=1

print(ans)
N,x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
cnt=0
for b in a:
  x-=b
  if x>=0:
    cnt+=1
  else:
    break
if x>0:
  print(cnt-1)
else:
  print(cnt)
N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
sum = 0

for i in children:
    sum += i

if sum < x:
    print(N - 1)
elif sum == x:
    print(N)
else:
    cnt = 0
    for i in children:
        if x - i < 0:
            break
        else:
            x -= i
            cnt += 1
    print(cnt)
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

A = sorted(A)

i = 0
while i < N:
    if A[i] <= x:
        x -= A[i]
        i += 1
    else:
        break

if i == N and x > 0:
    i -= 1

print(i)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,x = iim()
A = sorted(iil())
count = 0
for i in A:
    x -= i
    count += 1
    if x < 0:
        print(count-1)
        exit()
    elif x == 0:
        print(count)
        exit()
print(count-1)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

if x < a[0]:
	print(0)
	exit()

if sum(a) < x:
	print(n - 1)
	exit()

cnt = 0
for i in range(n):
	if a[i] <= x:
		cnt += 1
		x -= a[i]

print(cnt)
n,x= list(map(int, input().strip().split()))
a= list(map(int, input().strip().split()))
a.sort()
count=0
f=0
for i in range(n):
    count+=a[i]
    if count>x:
        f=i
        break
if count<x:
    print(n-1)
elif count==x:
    print(n)
else:
    print(f)
n, x = map(int, input().split())
li = sorted(map(int, input().split()))
ans = 0
for a in li:
    if x >= a:
        x -= a
        ans += 1
if ans == n and x > 0:
    ans -= 1
print(ans)
n,x,*a=map(int,open(0).read().split())
a.sort()
for i in range(n):
  x-=a[i]
  if x<0:
    print(i)
    break
  elif x==0:
    print(i+1)
    break
else:
  print(n-1)
n,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = [0] * (n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]

ans = 0
for i in range(n):
    if x >= s[i+1]:
        ans = i+1
if x > s[n]:
    ans -= 1
print(ans)
N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
cnt=0
while cnt<=N-1 and x>=a[cnt]:
  x-=a[cnt]
  if cnt==N-1 and x!=0:
    pass
  else:
    cnt+=1
print(cnt)
N,x = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
#x個のお菓子を配る。
#和がxを越えないように最も多い数のaを選ぶ
A.sort()
ans = 0
cur = 0
for a in A:
    cur += a
    if cur > x:
        print(ans)
        exit()
    ans += 1
if cur == x:print(N)
else:print(ans-1)
N,x = map(int, input().split())
A = [int(i) for i in input().split()]

"""
「ちょうど」でｷｬｯｷｬ
"""

A.sort()

from itertools import accumulate

A = tuple(accumulate(A))

ans = N - 1
for i,a in enumerate(A):
    if x > a:
        pass
    elif x == a:
        ans = i + 1
        break
    else:
        ans = i
        break

print(ans)
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
elif sum(a) < x:
    print(n-1)
else:
    a.sort()
    ans = 0
    for i in a:
        if i > x:
            break
        else:
            x -= i
            ans += 1
    print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
# box = []
cnt = 0

for i in range(n):
    x = x - a[i]
    if(x >= 0):
        cnt += 1
    else:
        break
if(x != 0 and cnt == n):
    cnt -= 1
print(cnt)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in a:
    x-=i
    if x<0:
        print(ans)
        break
    ans += 1
else:
    if x==0:
        print(ans)
    else:
        print(ans-1)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(n):
    x -= a[i]
    if x>0:
        count += 1
    elif x==0:
        count += 1
        break
else :
    if x>0 :
        count -= 1   
        
print(count)
n, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for a in A:
    x -= a
    if x >= 0:
        ans += 1
    else:
        break
if x > 0:
    ans -= 1
print(ans)
n,x=map(int,input().split())
a=list(map(int, input().split()))

ans=0
rest=x
target=sorted(a)
if sum(target)<x:
    print(n-1)
elif sum(target)==x:
    print(n)
else:
    for i in range(n):
        rest-=target[i]
        if rest<0:
            ans=i
            break
        if rest==0:
            ans=i+1
            break
    print(ans)
n,x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
if x<min(a):
    ans = 0
elif x>sum(a):
    ans = n-1
else:
    for i in range(1,n+1):
        if x>=sum(a[:i]):
            ans+=1
        else:
            break        
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            count += 1
    elif x >= a[i]:
        count += 1
        x -= a[i]
print(count)
N, x = map(int, input().split())
a = [int(i) for i in input().split()]

res = 0
if x == sum(a):
  res = N
elif x > sum(a):
  res = N -1
else:
  a.sort()
  while x > 0:
    if x >= a[0]: res += 1
    x -= a.pop(0)

print(res)
n , x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cou = 0
for i in range(n):
    cou += a[i]
    if cou == x:
        print(i + 1)
        break
    elif cou > x:
        print(i)
        break
else:        
    print(n-1)
# -*- coding: utf-8 -*-


#----------
n,x = list(map(int, input().rstrip().split()))
a_list = list(map(int, input().rstrip().split()))
#----------
a_list.sort()
x_remain=x

result = -1
for i in range(n):
    x_remain -= a_list[i]
    
    if x_remain == 0:
        result = i+1
        break
    if x_remain < 0:
        result = i
        break

if result == -1 :
    result = n-1

print(result)
n, x = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
ans = 0
for i in range(n):
  if a[i] <= x:
    ans += 1
    x -= a[i]
    if i == n-1 and x != 0:
      ans -= 1
  else:
    break
print(ans)
n,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()
c = 0
i = 0
while(True):
    if(i >= n - 1):
        break
    if(x < a[i]):break
    c += 1
    x -= a[i]
    i += 1
if(x == a[i]):c += 1
print(c)
n,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
for a in A[:-1]:
  x-=a
  if x>=0:
    ans+=1
  else:
    break
if A[-1]==x:
  ans+=1
print(ans)
N, x = map(int, input().split())
a = sorted(map(int, input().split()))

ans = 0
for i in range(N):
    ans += 1
    x -= a[i]
    if x < 0:
        ans -= 1
        break
if x > 0:
    ans -= 1
print(max(ans, 0))
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
count = 0
flag = True

for i in range(len(A)):
  if x - A[i] >= 0:
    x -= A[i]
    count += 1
  else:
    flag = False
    break
    
if x > 0 and flag:
  print(count-1)
else:
  print(count)
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

if x < a[0]:
    print(0)

else:
    cnt = 0
    for i in range(n-1):
        if x - a[i] < 0:
          break
        cnt += 1
        x -= a[i]
    print(cnt+1 if x == a[-1] else cnt)
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N,x = map(int, input().split())
    vec =list(map(int, input().split())) 
    vec.sort()
    SUM = 0
    i = 0
    for p in range(N):
        SUM += vec[p]


        # print(SUM)
        if(SUM > x):
            break
        
        i += 1

    if(x > sum(vec)):
        i -= 1
    print(i)
        
if __name__ == '__main__':
    solve()
N,X=map(int,input().split())
ai=list(map(int,input().split()))
ai.sort()
sum_of_the_candy=0
ans=0
if sum(ai)==X:
	ans=N
elif sum(ai)<X:
	ans=N-1
else:
	for i in range(N):
		sum_of_the_candy=sum_of_the_candy+ai[i]
		if sum_of_the_candy <= X:
			ans = ans +1
		else:
			break
print(ans)
n,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
while True:
    if count > n-1:
        if x == a[n-1]:
            print(count)
            exit()
        else:
            print(count-1)
            exit()
    if a[count] < x:
        x-=a[count]
        count += 1
    elif a[count] == x:
        print(count+1)
        exit()
    else:
        print(count)
        exit()
n, x = map(int, input().split())
a = sorted(map(int, input().split()))
rest = x
ans = 0
for i in range(n) :
    if rest > a[i] :
        if i != n-1 :
            rest -= a[i]
            ans += 1
        else :
            print(ans)
            break
    elif rest == a[i] :
        ans += 1
        print(ans)
        break
    else :
        print(ans)
        break
else :
    print(ans)
N, x = map(int, input().split())
L = list(map(int, input().split()))
l = sorted(L)
c = 0
if sum(L) < x:
  print(len(l)-1)
else:
  for i in range(N):
    if x < l[i]:
      break
    x = x - l[i]
    c += 1
    
  print(c)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
total = 0
if x-sum(a) == 0:
  print(n)
elif x >= sum(a) and x-sum(a) != 0:
  print(n-1)
else:
  for i in range(n):
    total += a[i]
    if total > x:
      print(i)
      break
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
y = x
if y < a[0]:
    print(0)
else:
    for i in range(n):
        x = x - a[i]
        if x > 0:
            continue
        elif x == 0:
            print(i+1)
            break
        elif x < 0:
            print(i)
            break
if x > 0 and y > a[0]:
    print(n-1)
def main():
    N, x = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()

    ans = 0
    for i in range(len(A)):
        if i == (len(A) - 1):
            if A[i] == x:
                ans += 1

        else:
            if A[i] <= x:
                ans += 1
                x -= A[i]
    print(ans)
    
if __name__ == "__main__":
    main()
N, x = map(int, input().split())
children = sorted(list(map(int, input().split())))

count = 0
for child in children:
    if x >= child:
        x -= child
        count += 1
    else:
        break
else:
    if x != 0:
        count -= 1

print(count)
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
kids = 0
ans = 0
for i in range(n):
    kids += l[i]
    if kids <= x:
        ans += 1
    else:
        break

if sum(l) >= x:
    print(ans)
else:
    print(ans - 1)
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
ans = 0
for i,a in enumerate(A):
    x = x-a
    if x<0:
        break
    ans+=1
print(ans-(x>0))
n, x = map(int, input().split())
a = sorted([int(i) for i in input().split()])
ans = 0

for i in range(n):
	x -= a[i]
	if x >= 0:
		ans += 1


if x > 0:
	print(ans -1)
else:
	print(ans)
n,x=map(int,input().split())
l=sorted(list(map(int,input().split())))

c=0
for i in l:
  x-=i
  if x<0:
    c+=1
    break
  else:
    c+=1

if x!=0:
  c-=1


print(c)
def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))

    A_sorted = sorted(A)

    res = 0

    for kids in A_sorted:
        x = x - kids
        
        if x >= 0:
            res += 1
    
    if x > 0:
        print(res - 1)
    else:
        print(res)

if __name__ == '__main__':
    main()
n,x = map(int,input().split())
a = list(map(int,input().split()))

a = sorted(a)

count = 0

for i in range(n - 1):
    if a[i] <= x:
        x -= a[i]
        count += 1
    else:
        break

if a[-1] == x:
    count += 1

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

if sum(li) < x:
    print(n-1)
    exit()

li.sort()
ans = 0

for i in li:
    x -= i
    if x >= 0:
        ans += 1

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

a_sort = sorted(a)
ans = 0

for i in range(n-1):
    if x - a_sort[i] >= 0:
        x -= a_sort[i]
        ans += 1
if a_sort[n-1] == x:
    ans += 1

print(ans)
N, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a.sort()
ans = 0
for i in range(N):
    if x < a[i]:
        x = 0
        break
    x -= a[i]
    ans += 1
if x > 0:
    ans -= 1

print(ans)
# A - Candy Distribution Again
count = 0
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
    x -= A[i]
    if(x < 0):
        break
    count += 1
if(x == A[N-1]):
    count += 1
        
print(count)
#22
N,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

if sum(a) ==x:
    print(N)
elif sum(a) < x:
    print(N-1)
else:
    for i in range(N):
        if sum(a[0:i+1]) >x:
            print(i)
            break
def resolve():
    '''
    code here
    '''
    N, x = [int(item) for item in input().split()]
    As = [int(item) for item in input().split()]
    As.sort()

    cnt = 0
    while x > 0 and cnt < N:
        x -= As[cnt]
        if cnt == N-1:
            if x == 0:
                cnt += 1
        else:
            if x >= 0:
                cnt += 1
    
    print(cnt)


if __name__ == "__main__":
    resolve()
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0
for i in range(N):
  if a[i] <= x:
    cnt += 1
    x -= a[i]
  else:
    break
if x > 0:
  cnt -= 1
print(cnt)
N, x = map(int, input().split())
a = list(map(int, input().split()))

cont = 0

for y in sorted(a):
    if x >= y:
        cont += 1
        x -= y

if x != 0:
    cont = cont-1
print(cont)
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in a:
    if x>=i:
        count += 1
        x -= i
    else:
        break
print(count)
N, x = map(int, input().split())
A = sorted(map(int, input().split()))

if sum(A) == x:
    print(x)

else:
    c = 0
    for ai in A:
        x -= ai
        if x <= 0:
            break
        c += 1

    print(c + 1 if x == 0 else c)
import sys
input = sys.stdin.readline

def main():
    N, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    for i, a in enumerate(sorted(a_list), start=1):
        x -= a
        if x < 0:
            break
    if x >= 0:
        print(i)
    else:
        print(i-1)

if __name__ == '__main__':
    main()
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

s = 0
num = 0
for i in range(len(a)):
    if x >= a[i]:
        x -= a[i]
        num += 1
    else:
        break

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

ss = list(map(int, input().split(' ')))
    
r = x
count = 0    
for s in sorted(ss):
    if r - s < 0:
        break
    else:
        r -= s
        count += 1
print(count)
n,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
for a in A:
  x-=a
  if x>=0:
    ans+=1
  else:
    print(ans)
    break
N,x = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
#x個のお菓子を配る。
#和がxを越えないように最も多い数のaを選ぶ
A.sort()
ans = 0
cur = 0
for a in A:
    cur += a
    if cur > x:
        print(ans)
        exit()
    ans += 1
print(ans)
N,x=map(int, input().split())
A=sorted(list(map(int, input().split())))
cnt=0
for i in A:
  if x >= i:
    x -= i
    cnt+=1
  else:
    break
print(cnt)
N, x = [int(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ")]

lst.sort(reverse = True)
cnt = 0

for i in range(0,N):
  if x >= lst[i]:
    x -= lst[i]
    cnt += 1
  else:
    break
    
print(cnt)
n,x=map(int,input().split())

a=list(map(int,input().split()))

a.sort()

s=0
i=0

if n==0:
    print(0)
    exit()
elif sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i-1)
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0
for i in range(N):
  if a[i] < x:
    cnt += 1
    x -= a[i]
  else:
    break
if x > 0:
  cnt -= 1
print(cnt)
N,X = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
count = 0
for i in A:
    if X >= i:
        X = X - i
        count += 1
        print(X)
    else:
        break
if X > 0:
    count -= 1
print(max(count,0))
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in a:
    if x-i>=0:
        x -= i
        count += 1


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

a.sort()
count = 0

for i in a:
    if x >= i:
        x -= i
        count += 1
    else:
        pass
        
print(count)
def main():
    n, x = map(int, input().split())
    A = list(map(int, input().split()))

    A_sorted = sorted(A)

    res = 0

    for kids in A_sorted:
        if x - kids >= 0:
            x = x - kids
            res += 1
    
    print(res)

if __name__ == '__main__':
    main()
N,x = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

ans = 0
for i in range(N):
  if x > A[i]:
    ans += 1
    x -= A[i]
  elif x == A[i]:
    print(ans+1)
    break
  elif i+1 == N:
    print(ans -1)
    break
  else:
    print(ans)
    break
N,x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
#昇順に並べ替える
sort_a = sorted(a)

for i in range(len(a)):
    if x >= sort_a[i]:
        count += 1
        x -= sort_a[i]
        continue
    else:
        continue
    break
print(count)
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
  if a[i]<=x:
    x=x-a[i]
    ans=ans+1
if ans>0 and x>0:
  ans=ans-1
print(ans)
from itertools import accumulate
N, X = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
p = list(accumulate(a))

result = 0
break_idx = 0
for i, x in enumerate(p):
  if X < x:
    break_idx = i
    break
  result += 1
  
if result != 0 and p[break_idx-1] != X:
  result -= 1

print(result)
def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    if sum(a) <= x:
        print(N)
        return
    for i in range(N):
        x -= a[i]
        if x < 0:
            break
    ans = i
    print(ans)

if __name__ == "__main__":
    main()