Problem:
 Score : 200 points    Problem Statement There are N children, numbered 1, 2, ..., N .  Snuke has decided to distribute x sweets among them.
He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i ( 1 \leq i \leq N ), Child i will be happy if he/she gets exactly a_i sweets.
Snuke is trying to maximize the number of happy children by optimally distributing the sweets.
Find the maximum possible number of happy children.      Constraints  All values in input are integers.  2 \leq N \leq 100  1 \leq x \leq 10^9  1 \leq a_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  x  a_1  a_2  ...  a_N       Output Print the maximum possible number of happy children.        Sample Input 1 3 70
20 30 10      Sample Output 1 2  One optimal way to distribute sweets is (20, 30, 20) .       Sample Input 2 3 10
20 30 10      Sample Output 2 1  The optimal way to distribute sweets is (0, 0, 10) .       Sample Input 3 4 1111
1 10 100 1000      Sample Output 3 4  The optimal way to distribute sweets is (1, 10, 100, 1000) .       Sample Input 4 2 10
20 20      Sample Output 4 0  No children will be happy, no matter how the sweets are distributed.

Solution (Python):
import sys
input = sys.stdin.readline

N, X = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

ans = 0
for i in range(N):
    a = L[i]
    
    if X >= a:
        X -= a
        ans += 1

if ans == N and X > 0:
    ans -= 1
    
print(ans)

Solution (Python):
n, x = map(lambda x: int(x), input().split(' '))
a = list(map(lambda x: int(x), input().split(' ')))

a.sort()
result = 0
for candy in a:
    if x - candy < 0:
        break
    result += 1
    x = x - candy
else:
    if x > 0:
        result -= 1
print(result)

Solution (Python):
N, X = map(int, input().split())
A = sorted(list(map(int, input().split())))

c, x = 0, X
for a in A:
	if x < a:
		break
	c += 1
	x -= a
else:
	if x:
		c -= 1

print(c)

Solution (Python):
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
t=1
for i in range(N):
    if x-A[i]>=0:
        ans+=1
        x-=A[i]
    else:
        t=0
if x==0:
    print(ans)
else:
    print(ans-t)

Solution (Python):
n,x=map(int,raw_input().split())
a=(map(int,raw_input().split()))

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

if x == 0:
    print(n)
elif x > 0:
    print(n-1)
else:
    print(count)

Solution (Python):
N,x = map(int,input().split())
A = list(map(int,input().split()))	
ans=0
A.sort()
for i in A:
    x=x-i
    if x >= 0:
        ans=ans+1
if x > 0:
    ans= ans-1
print(ans)

Solution (Python):
from sys import exit, stdin
N, X = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
ans = 0
for i in range(N):
  if A[i] <= X:
    X -= A[i]
    if i == N-1 and X == 0:
      ans += 1
    elif i != N-1:
      ans += 1
  else:
    print(ans)
    exit()
print(ans)

Solution (Python):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
cnt=0
for a_ in a:
     if x>=a_:
          x-=a_
          cnt+=1
     else:
          break
else:
     if x>0:
          cnt-=1
print(cnt)

Solution (Python):
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]:
    x -= a[i]
    ans += 1
if ans == n and x > 0:
  ans -= 1
print(ans)

Solution (Python):
n, x = list(map(int, input().split()))
aaa = list(map(int, input().split()))

aaa.sort()
ans = 0
for a in aaa:
  if a > x:
    break
  ans += 1
  x -= a
else:
  if x > 0:
    ans -= 1
print(ans)

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
count=0

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

if x==a[-1]:
    count+=1
print(count)

Solution (Python):



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

sort_a = sorted(a)

cnt = 0
sum_a = 0
for i in sort_a:
    x -= i
    if x >= 0:
        cnt += 1
    else:
        break

if x > 0:
    cnt -= 1

print(cnt)

Solution (Python):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans,j=0,0
for i in a:
    ans+=1
    j+=i
    if j>=x:break
if j!=x:ans-=1
print(ans)

Solution (Python):
n, x = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a.sort()
ans = 0
for item in a[:-1]:
    if x >= item:
        ans += 1
        x -= item
    else:
        break
if a[-1] == x:
    ans += 1
print(ans)

Solution (Python):
n, x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
for i in a:
  if i > x:
    break
  ans += 1
  x -= i
else:
  if x > 0:
    ans -= 1
print(ans)

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0

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

        else:
            break
else:
    memo = x - sum(a)
    x -= memo
    a[-1] += memo
    
    for i in range(N):
        if x > 0:
            if x >= a[i]:
                ans += 1
            x -= a[i]

        else:
            break
    

print(ans)

Solution (Python):











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


a.sort()


acm = 0
ans = -1
for i in range(n):
    acm += a[i]
    
    if acm == x:
        ans = i + 1
        break
    
    elif acm > x:
        wk_acm = acm - a[i]
        j = i + 1
        while j < n:
            if wk_acm + a[j] == x:
                ans = i + 1
                break
            j += 1
        if j >= n:
            ans = i
        break


if i == n - 1 and x != acm:
    ans = n - 1


print(ans)

Solution (Python):
N,x=map(int,input().split())
t=list(map(int,input().split()))
if x > sum(t):
    print(N-1)
else:
    cnt=0
    total=0
    t=sorted(t)
    for T in t:
        total+=T
        if total <= x:
            cnt+=1
        else:
            break
    print(cnt)

Solution (Python):
N ,x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt = 0
for i in A:
  x -= i
  if x < 0:
    break
  cnt += 1
if x > 0:
    cnt -= 1
print(cnt)

Solution (Python):
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
sum = 0
for i in range(n):
        if x > 0:
                x -= a[i]
                sum += 1
if x != 0:
        sum -= 1
print(sum)

Solution (Python):
n,m=map(int,input().split())
hoge=list(map(int,input().split()))
hoge.sort()

if(sum(hoge)<m):
  print(n-1)
  exit()

ans=0
for i in range(n):
  if(hoge[i]<=m):
    ans+=1
    m-=hoge[i]
  else:
    break
print(ans)

Solution (Python):
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))

for i in range(1, N+1):
    if sum(A[:i]) == x:
        print(i)
        quit()
    if sum(A[:i]) > x:
        print(i-1)
        quit()
print(N - 1)

Solution (Python):
from bisect import bisect_right

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
SUM = [a[0]]

for i in range(1, n):
    SUM.append(SUM[-1]+a[i])

if SUM[-1] < x:
    print(n-1)
else:
    print(bisect_right(SUM, x))

Solution (Python):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
i=0
ans=0
while x>0 and i<n:
    if x>=a[i]:
        if i<n-1:
            x-=a[i]
            ans+=1
            i+=1
        else:
            if x==a[i]:
                ans+=1
            x-=a[i]
            i+=1

    else:
        break
print(ans)

Solution (Python):
n,x = [int(x) for x in input().split()]
a = list(map(int, input().split()))
sortA1 = sorted(a)
ans = 0
for i in range(n):
    x-=sortA1[i]
    if x >= 0:
        ans+=1
print(ans - (x > 0))

Solution (Python):
from itertools import accumulate

N, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A.sort()

count = 0
for a in A:
    x -= a
    if x < 0:
        break
    count += 1
print(count - (x > 0))

Solution (Python):
N, x =map(int, input().split())
a = sorted(map(int, input().split()))

i = 0

while (i<N) and (x>=0):
    x -= a[i]
    if x>=0:
        i += 1

if (i == N) and (x>0) :
    print(N-1)
else:
    print(i)

Solution (Python):
n, x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

t = 0
c = 0
p = sum(a)
if x > p:
        print(n - 1)
elif x == p:
        print(n)
else:
        for i in range(n):
                t += a[i]
                if t <= x:
                        c += 1
                else:
                        break
        print(c)

Solution (Python):
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for n in a[:-1]:
    if n > x:
        break
    ans += 1
    x -= n
if a[-1] == x:
    ans += 1
print(ans)

Solution (Python):
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
calc = 0
ans = 0
for i, aa in enumerate(a):
    calc += aa
    if calc > x:
        break
    else:
        ans += 1
if (i == n-1) & (ans == x):
    ans += 1
if calc < x:
    ans = i
print(ans)

Solution (Python):
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
i = 0
while x >= a[i] and i < N - 1:
	x -= a[i]
	i += 1
if x < a[i]:
	print(i)
	exit()
if i == N - 1:
	if x == a[i]:
		print(i + 1)
	else:
		print(i)

Solution (Python):
n, x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))

ans = 0
for e in a:
    x -= e
    if x < 0:
        break
    ans += 1

print(ans if x <= 0 else ans - 1)

Solution (Python):
n,x=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
for i in range(n):
  if x-arr[i]>=0:
    x-=arr[i]
  else:
    print(i)
    break
else:
  if x ==0:
    print(n)
  else:
    print(n-1)

Solution (Python):
import bisect
n,x=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
S=[]
s=0
for i in range(n):
  s+=A[i]
  S.append(s)
k=bisect.bisect(S,x)
if k<n and x==S[k]:
  k+=1
if k==n and x!=S[-1]:
  k-=1
print(k)

Solution (Python):
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()

from itertools import accumulate
Acumsum = list(accumulate(A))

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

if i==N and Acumsum[-1]!=x:
    print(N-1)
else:
    print(i)

Solution (Python):
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 -= a[i]
        ans += 1
    else:
        break
if x == 0 or ans != N:
    print(ans)
else:
    print(max(ans - 1, 0))

Solution (Python):
N,x=map(int,input().split(" "))
a=sorted(map(int,input().split(" ")))

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

print(s)

Solution (Python):
n,x=map(int,input().split())
a=sorted([int(i) for i in input().split()])
cnt=0
for j in range(n):
    if x>=a[j]:
        if j!=n-1:
            x-=a[j]
            cnt+=1 
        elif x==a[j]:
            x-=a[j]
            cnt+=1
    else :
        break
print(cnt)

Solution (Python):
n,x,*a=map(int,open(0).read().split())
s=0
for c in sorted(a):
  if x>=c and s<n-1:
    s+=1
  elif x==c and s==n-1:
    s+=1
  x-=c
  if x<=0:break
print(s)

Solution (Python):
N,X=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
answer=0
for b in range(N):
  if X>=a[b]:
    if b!=N-1:
      X-=a[b]
      answer+=1
    elif X==a[b]:
      answer+=1
  else:
    break
print(answer)

Solution (Python):
n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for a in A:
    if a <= x:
        cnt += 1
    x -= a
if x > 0:
    cnt -= 1
print(cnt)

Solution (Python):
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
if x > sum(a):
    print(n-1)
    exit()
if x == sum(a):
    print(n)
    exit()
for i in range(n):
    a.pop(0)
    if len(a) == 0:
        print(0)
        exit()
    if x >= sum(a):
        print(n-i-1)
        exit()

Solution (Python):
n,x=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
for i in range(n):
  if x-arr[i]>=0:
    x-=arr[i]
  else:
    print(i)
    break
else:
  if x==0:
    print(n)
  else:
    print(n-1)

Solution (Python):
N, x = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for i, a in enumerate(sorted(A)):
    if a <= x:
        if i == N - 1 and a < x:
            break
        else:
            cnt += 1
            x -= a
    else:
        break

print(cnt)

Solution (Python):
N, x = [int(x) for x in input().split()]
a_s = [int(x) for x in input().split()]

a_s.sort()
ans = 0
X = 0
for a in a_s[:-1]:
    if X + a <= x:
        X += a
        ans += 1
    else:
        break
if a_s[-1] == x - X:
    ans += 1

print(ans)

Solution (Python):
n, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

cnt = 0
for a_ in sorted(a):
    if x >= a_:
        x -= a_
        cnt += 1 
    else:
        x = 0
        break

if x > 0:
    cnt -= 1
print(cnt)

Solution (Python):
a,b=map(int, input().split())
c=[int(i) for i in input().split()]
c.sort()
ans=0
for i in c:
    b=b-i
    if b>=0:
        ans=ans+1
if b>0:
    ans=ans-1
print(ans)

Solution (Python):
N, x=map(int, input().split())
list_=list(map(int, input().split()))

m_list=sorted(list_)

if sum(m_list)==x:
    print(N)
elif sum(m_list)<x:
    print(N-1)
else:
    ans=0
    for i in m_list:
        x-=i
        if x>=0:
            ans+=1
        else:
            break

    print(ans)

Solution (Python):
N, x = map(int, input().split())
fav = sorted(map(int, input().split()))
oura=[int()]*N

oura[0] = fav[0]
for i in range(len(fav)-1):
    oura[i+1] = oura[i] + fav[i+1]


sai = 0
for j in range(len(oura)):
    if oura[j] > x:
        sai = j
        break
    elif j != N-1:
        continue
    elif oura[N-1] == x:
        sai = N
    else:
        sai = N-1

print (sai)

Solution (Python):
N,x=map(int,input().split())
A=sorted(list(map(int,input().split())))
num=0
ans=0
for i in range(N):
    num=num+A[i]
    if x<num:
        ans=i
        break
    elif i!=N-1:
        continue
    elif num==x:
        ans=N
    else:
        ans=i
print(ans)

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

Solution (Python):
N,x = map(int, input().rstrip().split())
a = list(map(int, input().rstrip().split()))
a.sort()
counter = 0
for i,n in enumerate(a):
    x -= n
    if x >= 0 and i != N-1:
        counter += 1
    elif x == 0:
        counter += 1
        break
    else:
        break
print(counter)

Solution (Python):
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(N):
    if i == N-1:
        if x == a[i]:
            ans += 1
        break
    if x - a[i] >= 0:
        x -= a[i]
        ans += 1
    else:
        break
print(ans)

Solution (Python):
n,x=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])

if sum(a)==x:
    print(n)
elif sum(a)<x:
    print(n-1)
else:
    ans=0
    for i in a:
        x-=i
        if x>=0:
            ans+=1
        else:
            break
    print(ans)

Solution (Python):
N,x = (list(map(int,input().split())))
a = (list(map(int,input().split())))
a.sort()
out = 0
for i in a:
    if x>=i:
        x-=i
        out +=1
    else:
        break
else:
    if x != 0:
        out -=1
print(out)

Solution (Python):
N, x = map(int, input().split())
a = sorted(int(x) for x in input().split())
ans = 0
for ai in a:
    x -= ai
    if x < 0:
        break
    ans += 1
if 0 < x:
    ans -= 1
print(ans)

Solution (Python):
N,x = map(int,input().split())
a_ = list(map(int,input().split()))
a_.sort()

if x == sum(a_):
  print(N)
else:
  sum_a = 0
  for i in range(N):
    if x >= sum_a + a_[i]:
      sum_a += a_[i]
    else:
      break
  print(i)

Solution (Python):
def main():
    N,x = map(int,input().split())
    num = x
    a_s = list(map(int,input().split()))
    a_s.sort()
    cnt = 0
    for i,a in enumerate(a_s):
        if num >= a:
            num -= a
            cnt += 1

    if cnt == N and num > 0:
        cnt -= 1
    print(cnt)
if __name__ == '__main__':
    main()

Solution (Python):
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:break
  else:
    ans+=1
    x-=a[i]
    if i==n-1 and x!=0:ans-=1
print(ans)

Solution (Python):
N, x = map(int, input().split())
an = map(int, input().split())

count = 0
san = sorted(an)
for a in san:
    x -= a
    if x < 0:
        break
    count += 1
if x > 0:
    count -= 1

print(count)

Solution (Python):
n, x = map(int, input().split())
alist = list(sorted(map(int, input().split())))

if sum(alist) == x:
  print(n)
else:
  suma = 0
  k = 0
  for a in alist:
    if suma <= x:
      suma += a
      k += 1
  print(k - 1)

Solution (Python):
n, x = map(int,input().split())
a = list(map(int, input().split()))

a.sort()
count = 0
for ai in a:
    if x >= ai:
        x -= ai
        count += 1
    else:
        x = 0
if x > 0:
    count -= 1

print(count)

Solution (Python):
N,X = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

ans = 0
for a in A:
    if X-a < 0: break
    X -= a
    ans += 1
else:
    if X:
        ans -= 1
print(ans)

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
a.sort()
for i in range(N):
    if x >= a[i]:
        count += 1
        x -= a[i]
    else:
        break
else:
    if x != 0:
        count -= 1
print(count)

Solution (Python):

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

Solution (Python):
N, x = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
 
ans = 0
for a in A:
  if a <= x:
    ans += 1
    x -= a
  else:
    x -= a
    break
if x > 0: ans -= 1
    
print(ans)

Solution (Python):
""" AtCoder """

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

a.sort()

ans = 0

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

print(ans)

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
ans=0
while x>0:
  if x==0:
    break
  elif len(a)==0:
    ans-=1
    break
  if a[-1]<=x:
    x-=a.pop()
    ans+=1
  else:
    break
print(ans)

Solution (Python):
import numpy as np
N, x = map(int, input().split())
a = np.array(list(map(int, input().split())))
a.sort()
s = np.cumsum(a)
b = (s <= x)
if b.all():
  if s[-1] == x:
    c = b.sum()
  else:
    c = b.sum() - 1
elif b.any():
  c = b.sum()
  r = x - s[c-1]
  if (r == a[c:]).any():
    c += 1
else:
  c = 0
print(c)

Solution (Python):
N,x=map(int,input().split())

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

a.sort()

if x>sum(a):
    print(N-1)
elif x==sum(a):
    print(N)
else:
    ans=0
    for i in range(N):
        if x<=0:
            break
        elif x>=a[i]:
            ans+=1
            x-=a[i]
    print(ans)

Solution (Python):
N, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

a = sorted(a)

pointer = 0
score = 0
while(x>=0 and pointer<N):
    x = x-a[pointer]
    score+=1
    pointer+=1

if(x!=0):
    score-=1
print(score)

Solution (Python):
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(n):
    x -= a[i]
    if x<0:
        print(i)
        exit()
    elif x==0:
        print(i+1)
        exit()
print(n-1)

Solution (Python):
n, x = map(int, input().split())
l = list(map(int, (input().split())))
l.sort()
count = 0
total = x
for i in l:
    if total < i:
        break
    total -= i
    count += 1
else:
    if total > 0:
        count -= 1
print(count)

Solution (Python):

'''
問題
N人の子供がいる
x個のお菓子をすべて配り切らなければならない
お菓子をもらわないこどもがいてもよい
子供iはちょうどai個のおかしをもらうと喜ぶ
喜ぶ子供の人数の最大値は?

考察
aiを小さい順にソートし,xから順番にaiを引いていく
'''

N,x = map(int,input().split(' '))
A = sorted(list(map(int,input().split(' '))))

ans = 0

for a in A:
	if x>=a:
		ans += 1
		x -= a
	elif x<a:
		break


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

print(str(ans))

Solution (Python):
N,x = map(int,input().split())
alist = list(map(int,input().split()))
alist.sort()
counter = 0
for i in range(N):
    x -= alist[i]
    if x>=0:
        if i!=N-1:
            counter += 1
        else:
            if x==0:
                counter += 1
    else:
        break
print(counter)

Solution (Python):
import sys
input = sys.stdin.readline

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

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

Solution (Python):
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
frag = False
count = 0
for i in range(len(a)):
    if x >= a[i]:
        count += 1
        x -= a[i]
    else:
        frag = True
        break
if not frag and x != 0:
    count -= 1
print(count)

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = list(sorted(a))

X = x
ans = 0
for i, aa in enumerate(a, 0):
    if X >= aa:
        if i == N - 1:
            if X == aa:
                ans += 1
        else:
            X -= aa
            ans += 1
    else:
        break
print(ans)

Solution (Python):
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))

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

Solution (Python):
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 and i!=N-1:
        ans+=1
        x-=a[i]
    if i==N-1and x==a[i]:
        ans+=1
print(ans)

Solution (Python):
N,x = map(int, input().split())
A = list(map(int, input().split() ) )

A = sorted(A)

ans = 0
for a in A:
  if x >= a:
    ans += 1
    x -= a

if x > 0 and ans == N:
  ans -= 1
elif x > 0 and ans < N:
  pass
print(ans)

Solution (Python):
def solve():
    N,x=map(int,input().split())
    a=list(map(int,input().split()))
    a=sorted(a)
    ans = 0
    for i,ai in enumerate(a):
        x -= ai
        if x == 0:
            return i + 1
        elif x < 0:
            return i
    return N - 1

print(solve())

Solution (Python):
N, x = [int(j) for j in input().split()]
a = sorted(list(map(int, input().split())))
sum = 0
flag = True

for i in range(N):
    sum += a[i]
    if sum > x:
        flag = False
        break

if sum != x:
    flag = False
    
print(i+1 if flag else i)

Solution (Python):
N,x=(int(i) for i in input().split())
lst=[int(i) for i in input().split()]
lst.sort()
ans=0
for i in range(N):
  if x==0:
    break
  if lst[i]<=x:
    x-=lst[i]
    ans+=1
  if lst[i]>x:
    break
  if ans==N-1:
    if lst[N-1]==x:
      x=0
      ans+=1
    else:
      break
print(ans)

Solution (Python):
n,x=map(int,input().split())

a=[int(i) for i in input().split()]

a.sort()
i=0
ans=0

while x>0 and i<n:
    if x-a[i]>=0:
        x-=a[i]
        ans+=1
    else:
        x=0
    if i==n-1:
        if x>0:
            ans-=1
    i+=1

print(ans)

Solution (Python):
N, x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(len(a)):
    sum_a = sum(a[:i+1])
    if sum_a > x: 
        print(i)
        break
if sum(a) == x: 
    print(N)
elif sum(a) < x: 
    print(N-1)

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
ans=0
for i in range(len(a)):
    cnt+=a[i]
    if cnt>x:
        print(ans)
        break
    else:
        ans+=1
else:
    if cnt!=x:
        print(ans-1)
    else:
        print(ans)

Solution (Python):
n,x = map(int,input().split())
preA = list(map(int,input().split()))
A = sorted(preA)
ans = 0 if sum(A) >= x else -1
sm = 0
for a in A:
    sm += a
    if sm <= x:
        ans += 1
    elif sm == ans:
        ans += 15
        break
    else:
        break
print(ans)

Solution (Python):
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i, a in enumerate(A):
    x -= a
    if x <= 0:
        if x == 0:
            i += 1
        break
print(i)

Solution (Python):
inpl = lambda: list(map(int,input().split()))

N,x = inpl()
A = sorted(inpl())

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

if i == N and x > 0:
	print(N-1)
else:
	print(i)

Solution (Python):
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
ans = 0
for a in A:
    if x - a >= 0:
        x -= a
        ans += 1
    else:
        break
if ans == N and x > 0:
    ans -= 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
childs = list(map(int, input().split()))
if(m > sum(childs)):
    print(len(childs)-1)
else:
    count = 0
    childs.sort()
    for child in childs:
        if m >= child:
            m -= child
            count += 1
    print(count)

Solution (Python):
N,x = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
for i in range(len(l)):
    sum_l = sum(l[:i+1])
    if sum_l > x :
        print(i)
        break
if sum(l) == x:
    print(N)
elif sum(l) < x:
    print(N-1)

Solution (Python):
n,x = map(int,input().split())
an = list(map(int,input().split()))

an = sorted(an)

count = 0
for a in an:
	x -=a
	
	if x < 0:
		break
	
	count+=1
else:
	if 0 < x:
		count-=1
	
print(count)

Solution (Python):
n,x = map(int,input().split())
ass = list(map(int,input().split()))

ass = sorted(ass)

count =0
for i,a in enumerate(ass):
	if i == len(ass)-1:
		if a < x:
			break
		elif a == x:
			count+=1
			break
		else:
			break
			
	if x < a:
		break
			
	
	x -= a
	count += 1
	
print(count)

Solution (Python):
n, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < x:
  print(n-1)
  exit()
a.sort()
cnt = 0
i = 0
while i < n and a[i] <= x:
  cnt += 1
  x -= a[i]
  i += 1
print(cnt)

Solution (Python):
def main():
    n,x=list(map(int,input().split()))
    a=list(map(int,input().split()))
    a.sort()
    ans=0
    if(sum(a)<x):
        ans-=1
    for i in range(n):
        if(x-a[i]>=0):
            ans+=1
            x-=a[i]
    print(ans)


if __name__=="__main__":
    main()

Solution (Python):
N, x = map(int, input().split())
srt_a = sorted(map(int, input().split()))

sum_a = sum(srt_a)
if sum_a == x:
    
    ans = N
elif sum_a < x:
    
    ans = N - 1
else:
    
    cnt = 0
    while True:
        a = srt_a[cnt]
        if x >= a:
            x -= a
            cnt += 1
        else:
            break
    ans = cnt

print(ans)

Solution (Python):
N, X = map(int, input().split())
A = [int(a) for a in input().split()]

s = sum(A)
if s == X:
    print(N)
else:
    ans = 0
    A = sorted(A)
    for i in range(N-1):
        if sum(A[:i+1]) <= X:
            ans = i+1
            
    print(ans)

Solution (Python):
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

rest = x
i = 0
cnt = 0

while rest > 0 :
    if rest < a[i] :
        break
    rest -= a[i]
    i += 1
    if (i == N) :
        if (rest == 0) :
            cnt += 1
        break
    cnt += 1

print(cnt)

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = 0
ans = 0
for i in range(N):
    s += a[i]
    if s <= x and i < N - 1:
        ans += 1
    elif i == N - 1 and s == x:
        ans += 1
    else:
        break
print(ans)

Solution (Python):
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
i = 0
sum = 0

while x > sum and i < n:
    sum += a[i]
    i += 1

if sum == x:
    print(i)
else:
    print(i-1)

Solution (Python):
N,x=map(int,input().split())
a=sorted(map(int,input().split()))
count=0
for i in range(N-1):
    x=x-a[i]
    if x>=0:count+=1
if x==a[N-1]:count+=1
print(count)

Solution (Python):
n,x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
A.sort()

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

print(ans)

Solution (Python):
N, x = map(int, input().split())
aList = [int(x) for x in input().split()]


aList.sort()

total_child = 0
isEqual = False
for a in aList:
    if x == 0:
        isEqual = True
        break
    elif x < 0:
        break
    x -= a
    total_child += 1

    if x == 0:
        isEqual = True

if isEqual:
    print(total_child)
else:
    print(total_child - 1)

Solution (Python):
N, x = map(int, input().split())
aList = [int(x) for x in input().split()]
aList.sort()

score = 0
for a in aList:
    if x >= a:
        x -= a
        score += 1
    else:
        break

if x > 0:
    if score == len(aList):
        score -= 1
print(score)

Solution (Python):
a,b,*x=map(int,open(0).read().split())
x=sorted(x)
count=0
for s in x:
    b-=s
    if b<0:
        break
    count+=1
if b>0:
    print(count-1)
else:
    print(count)

Solution (Python):


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

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

Solution (Python):
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,num = IL()
a = IL()

a.sort()

cnt = 0
for i in range(N):
    if i != N-1:
        if num-a[i] > 0:
            num -= a[i]
            cnt += 1
        elif num-a[i] == 0:
            cnt += 1
            break
    else:
        if num-a[i] == 0:
            cnt += 1
print(cnt)

Solution (Python):
n, x = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
RA = []
q = 0
for i in range(n):
    q += A[i]
    RA.append(q)

if RA[-1] < x:
    ans = n - 1
elif RA[-1] == x:
    ans = n
elif RA[0] > x:
    ans = 0
else:
    for i in range(n):
        if RA[i] == x:
            ans = i + 1
            break
        elif RA[i] > x:
            ans = i
            break

print(ans)

Solution (Python):
N, x = list(map(int, input().split()))
a_list = list(map(int, input().split()))
a_list.sort()

count = 0
for a in a_list:
  x -= a
  count += 1
  if x < 0:
    break

if x != 0:
  count -= 1
print(count)

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

a.sort()

Ans = N
for i in range(N):
  x -= a[i]
  if x < 0:
    Ans = i
    break

if Ans == N and x != 0:
  Ans = N - 1

print(Ans)

Solution (Python):
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):
    x -= A[i]
    if x < 0: break
    ans += 1
if x > 0: ans -= 1
print(ans)

Solution (Python):
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ret = 0
for i in a:
    x -= i
    if x < 0:
        break
    ret += 1
if x > 0:
    ret -= 1
print(ret)

Solution (Python):
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(N):
    x -= a[i]
    count += 1
    if x == 0:
        break
    elif x < 0:
        count -= 1
        break
    elif (i == (len(a) - 1)) and (x > 0):
        count -= 1
print(count)