peterverebics/CodeNet_Python_118 huggingface dataset:
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]
    else:
        break


if x>0  and i ==n-1:
    ans-=1
if ans < 0:
    ans =0

print(ans)
n,x = map(int,input().split())
line = sorted(list(map(int,input().split())))
count = 0
if sum(line) < x:
  count = n - 1
else:
  for i in range(n):
    left = x - line[i]
    if left > 0:
       count += 1
    elif left == 0:
      count += 1
      break
    else:
      count -= 1
      break
print(count)
n, x, *a = map(int, open(0).read().split())
a.sort()
cnt = 0
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        cnt += 1
    else:
        break
if x > 0:
    cnt -= 1
print(max(cnt,0))
#22
N,x = map(int,input().split())
a = list(map(int,input().split()))
cou =0
m = 0


a.sort()

for i in a:
    if i >x:
        break
    cou +=1
    x -= i
    
if x>0:
    for i in a:
        if x%i ==0:
            cou -=1
            break
        m = 0
        while x > i:
            x-=i
            m+=1
        if m !=0:
            cou -=1
        
print(cou)
n,x = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
count = 0
for i in range(n):
    if a_list[i] <= x:
        count += 1
        x = x-a_list[i]
    else:
        break
if x == 0:
    print(count)
else:
    print(count-1)
n, x = map(int, input().split())


a = list(map(int,input().split()))
  
a.sort(reverse = True)

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

A.sort(reverse=True)
ans = 0
for a in A:
    if x - a >= 0:
        x -= a
        ans += 1
if 0 < x:
    ans -= 1

print(max(ans, 0))
N, x = map(int, input().split())
a = list(map(int, input().split()))

i = 0
while len(a) > 0:
    if min(a) > x:
        break
    else:
        x -= min(a)
        a.remove(min(a))
        i += 1
print(i)
N, X = map(int, input().split())
lists = list(map(int, input().split()))

count = 0
for num in sorted(lists):
    X -= num
    if X == 0 and num == lists[-1]:
        print(count + 1)
        exit()
    if X >= 0 and num != lists[-1]:
        if num == lists[-1] and X > 0:
            break
        count += 1
        continue
    break
print(count)
N,x = map(int,input().split())
hito = input().split()
poo = [hito]
zyun = sorted(hito)

ok = 0
for i in range(len(poo)):
	if x-int(zyun[i])>=0:
		ok+=1
	else:
		print(ok)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

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

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

if x > 0:
	print(cnt - 1)
else:
	print(cnt)
n,x = map(int,input().split())

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

ans = 0

s.sort()

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

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

print(min(0,cnt))
import numpy as np

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

if sum(A) == x:
  print(N)
elif sum(A) < x:
  print(N-1)
else:
  cum = np.cumsum(A)
  if cum[0] > x:
    print(0)
  else:
    k = np.where(cum <= x)[0][0]
    print(k+1)
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
kids = 0
ans = 0
for i in range(n):
    print(kids, ans)
    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 = list(map(int, input().split()))

a.sort()
i = 0

while i < n:
    x -= a[i]
    if (x < 0):
        break
    i += 1

if (x != 0):
    i -= 1

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

a.sort()
count = 0

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

lists.sort()
count = 0
for i in lists:
  if x >= i:
    count += 1
    x -= i
  else:
    break
for i in lists:
  if x >= i:
    count -= 1
    x -= i
  else:
    break
print(count)
#Candy Distribution Again
n,x = map(int, input().split())
s= list(map(int,input().split()))

s.sort()
s.reverse
if s[0]>x:
    ans=1
else :
    ans=0
for i in s:
    x=x-i
    if x>=0:
        ans+=1
    else :
        break
if x!=0:
        ans-=1
print(ans)
import sys
input=sys.stdin.readline
n,x=map(int,input().split())
L=sorted(list(map(int,input().split())))
cnt=0
for i in L:
    x-=i
    if n>=0:
        cnt+=1
    else:break
print(cnt)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0

for i in a:
    if x >= min(a) and x >= i:
        x -= i
        count += 1
    else:
        pass
        
print(count)
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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 and ans:
    ans -= 1
print(ans)
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)
        break
    ans += 1
N, x = map(int, input().split())
a = list(map(int, input().split()))

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

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

  ans += 1

print(ans if x == 0 else ans - 1)
# AGC 027 A
N,X =map(int,input().split())
A =[int(j) for j in input().split()]
A.sort()
cnt=0
for a in A:
    if  X >=a:
        X-=a
        cnt+=1
if X !=0 and cnt>0:
    cnt-=1
print(cnt)
import numpy as np

n, x = map(int, input().split())
a = np.array(list(map(int, input().split())))
a = np.sort(a)
a = a.cumsum()
a = a[a <= x]
print(len(a))
N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
if sum(a)<x:
  print(N-1)
else:
  ans=0
  d=[0]*N
  for i in range(N):
    if x>=a[i]:
      x-=a[i]
      d[i]=1
  ans=d.count(1)
  if x>0:
    print(max(ans-1,0))
  else:
    print(ans)
n,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()

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

print(max(0,cnt))
# https://atcoder.jp/contests/agc027/tasks/agc027_a
n, x = map(int, input().split())
nums = [int(i) for i in input().split()]
nums.sort()
ans = 0
for i in range(n):
    for j in range(i, n):
        s = sum(nums[i:j + 1])
        if s == x:
            ans = max(ans, j - i + 1)
        elif s < x:

            ans = max(ans, j - i)

print(ans)
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = 0

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

if x != 0 and cnt != 0:
  cnt -= 1
else:
  pass

print(cnt)
N, x = map(int, input().split())
A = [int(i) for i in input().split()]
sorted_A = sorted(A)

i = 0
while i < N and x > 0:
    x -= sorted_A[i]
    i += 1

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

input = sys.stdin.readline


def main():
    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 i == N - 1 and x > 0:
        ans -= 1

    print(ans)


if __name__ == "__main__":
    main()
n,x = map(int,input().split())
A = sorted(map(int,input().split()))
ans = 0
for i in range(n):
  x -= A[i]
  ans += 1
  if x <= 0:
    ans -= 0
    break
print(ans)
n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if 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,*a=map(int, open(0).read().split())
a.sort()
for i in range(n):
    x-=a[i]
    if x<0:
      print(~-i)
      exit()
    elif x==0:
      print(i)
      exit()
print(n-1)
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:
        break
    elif x == 0:
        ans += 1
        break
    ans += 1
if x != 0:
    ans -= 1
if ans < 0:
    ans = 0
print(ans)
# -*- 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
       break

if result == -1 :
    result = n

print(result)
N,n=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

ans=0
i=0
while A[i]<=n:
  ans+=1
  i+=1
  if i==N:
    break
print(ans)
p_c,k_c=(int(x) for x in input().split())
al=list(map(int,input().split()))
al.sort(reverse=True)
count=0
for i in range(p_c):
	k_c=k_c-al[i]
	count+=1
print(count)
N,x = map(int,input().split())
a = sorted(map(int,input().split()),reverse=False)
ans = 0
for i in a:
    if x - i >= 0:
        x -= i
        ans += 1

if x > 0:
    ans -= 1

print(ans)
def resolve():
    n,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.sort()
    num=0
    cnt=0
    if x<l[0]:
        cnt=0
        print(cnt)
    else:
        for i in range(n-1):
            if num<x:
                num+=l[i]
                cnt+=1
        if x-num==l[n-1]:
            cnt+=1
        print(cnt)
resolve()
N, x = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
print(A)
c = 0
for i in A:
    x -= i
    if x >= 0:
        c += 1
    else:
        break

if x > 0:
    c -= 1

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

a.sort()
ans = 0
for ai in a:
    if x - ai < 0:
        break
    x -= ai
    ans += 1
if x > 0:
    ans -= 1
print(ans)
def resolve():
    n,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.sort()
    cnt=0
    if l[0]>x:
        print(0)
    else:
        for i in range(n):
            if l[i]<=x:
                x-=l[i]
                cnt+=1
        if x>0:
            cnt-=1
        print(cnt)
resolve()
N, x = map(int, input().split())
array = list(map(int, input().split()))
array = sorted(array, reverse=False)
if sum(array) <= x:
  print(N)
elif array[0] > x:
  print(0)
for i in range (N):
  if sum(array[0:i]) >= x:
    print(i)
    break
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
count = 0
for i in A:
  if x >= i:
    count += 1
    x -= i
  else:
    break
print(count)
n, x = map(int, input().split())


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

total=0
ans=0
for i in range(n):
  total += a[i]
  if total > x:
    ans = i
    break
  ans = i+1
  
print(ans)
n,x=map(int,input().split())
l1=list(map(int,input().split()))
l1.sort()
ans=0
while len(l1)>0:
    t1=l1.pop(0)
    if x>=t1:
        x-=t1
        ans+=1
if ans>0 and x>0:
    ans-=1
print (ans)
N, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
l = [0]*N
for i in range(N):
  if X >= A[i]:
    X -= A[i]
    l[i] = A[i]
ans = 0
for i in range(N):
  if A[i] - l[i] == 0:
    ans += 1
if X != 0:
  ans -= 1
print(ans)
N,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

count = 0
total = 0
for i in range(N):
    if total <=x:
        count += 1
        total += a[i]
    else:
        break
if total < x:
    count -= 1
print(count)
N, x = map(int,input().split())
A = list(map(int,input().split()))
A.sort
ans = 0
for i in range(len(A)):
    x = x-A[i]
    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()))
a = sorted(a)
count = 0
while(x >= 0):
  if(count == N):
    break
  tmp = a.pop(0)
  if(x >= tmp):
    x = x - tmp
    count += 1
  else:
    break
print(str(count))
n,x= map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans= 0

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

if ans == n and X >0 :
    ans -=1     
       
    
print(ans)
N,x=map(int,input().split())
A=list(map(int,input().split()))
A_1=sorted(A)
num=0
total=0
if A[0]>x:
    num=0
if sum(A_1)>=x:
    for i in range(N):
        total+=A_1[i]
        if total==x:
            num+=1
            break
        elif total>x:
            num-=1
            break
        else:
            num+=1

else:
    num=N-1
print(num)
N,x = map(int,input().split())
a = list(map(int,input().split()))

A = sorted(a)

n = 0

for i in A:
  x -= i
  n += 1
  if x<=0:
    break
  
print(n-1)
#22
N,x = map(int,input().split())
a = list(map(int,input().split()))
cou =0

a.sort()

for i in a:
    if i >x:
        break
    cou +=1
    x -= i
    
if x>0:
    for i in a:
        if x%i ==0:
            cou -=1
            break
        while x > i:
            x-=i
        cou -= 1
print(cou)
n,x = map(int,input().split())
line = sorted(list(map(int,input().split())))
count = 0
if sum(line) < x:
  count = n - 1
else:
  for i in range(n):
    left = x - line[i]
    if left > 0:
       count += 1
    elif left == 0:
      count += 1
      break
    else:
      count -= 1
      break
  if count < 0:
    count = 0
print(count)
n,x = map(int,input().split())
al = list(map(int,input().split()))
al.sort()
c = 0
for a in al:
  if x >= a:
    c += 1
    x -= a
print(c)
def main():
    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:
            break
    ans = i
    print(ans)

if __name__ == "__main__":
    main()
n,x = map(int,input().split())
a_inputs = sorted([int(i) for i in input().split()])

ans=0
while a_inputs:
    if a_inputs[0]>x:
        break
    else:
        a = a_inputs.pop(0)
        x-=a
        ans+=1
if x!=0 and ans!=0:
    ans-=1
print(ans)
N, x = map(int, input().split())
A = sorted(map(int, input().split()))

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

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

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

sum_cost = 0
ans = 0
for v in a:
    sum_cost += v
    if sum_cost <= x:
        ans += 1
    else:
        sum_cost -= v
        break

if sum_cost != x:
    ans -= 1
print(max(ans, 0))
N,x = map(int,input().split())
hito = input().split()
poo = [hito]
zyun = sorted(hito)

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

cont = 0

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

if x != 0:
    cont -= 1

print(cont)
from itertools import accumulate
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = accumulate(a)
ans = sum([1 for i in c if i <= x])
print(ans if x in c else ans - 1)
n,x = map(int,input().split())
al = list(map(int,input().split()))
al.sort()
c = 0
for a in al:
  if x >= a:
    c += 1
    x -= a
if x > 0:
  c -= 1
print(c)
N,x = map(int,input().split())
AAA = map(int,input().split())
AA = list(AAA)
AA.sort()
total = 0
count =0
for i in AA:
  total += i
if total == x:
  ans = N
elif total < x:
  ans = N-1
else:
  for i in AA:
    if x >= i:
      x -=1
      count +=1
  ans = count
print(ans)
a,b=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
if sum(L)==b:
  print(a)
  exit()
for i in range(a):
  if b-L[i]<0:
    print(i)
    exit()
print(i)
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
S = 0
ans = 0
for a in A:
    ans += 1
    if S + a > x:
        break
    else:
        S += a

print(ans-1)
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(len(A)):
  if x < min(A):
    print(cnt)
    break
  elif i == len(A)-1:
    print(cnt+1)
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1
N, X = map(int, input().split())
la = sorted(list(map(int, input().split())))

print(la)

if X < la[0]:
    print(0)
elif X > sum(la):
    print(N-1)
elif X == sum(la):
    print(N)
else:
    j = 0
    while X > 0:
        X = X - la[j]
        j += 1
    print(j)
N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
else:
  i += 1
print(i-1)
N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
sum = 0

for i in range(N):
    sum += children[i]
    if sum >= x:
        print(i + 1)
        break
N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
for i in range(N):
    if M - int(L[0]) >= 0:
        M -= int(L[0])
        total += 1
        L.pop(0)
        
print(total)
N,x = map(int,input().split())
A = list(map(int,input().split()))

X = 1
ans = 0

while x >= X:
    ans += A.count(X)
    x += -X*(A.count(X))
    X += 1

if ans !=0 & x!=0:
    ans += -1

print(ans)
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt=0
i=0
A.append(X+1)
flag=0
while True:
    if A[i]<=X:
        X-=A[i]
        cnt+=1
        i+=1
        flag=1
    elif X==0:
        break
    else:
        if flag==1:
            cnt-=1
        break
print(cnt)
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
if count != n:
    print(count)
else:
    print(n-1)
from itertools import accumulate
import bisect
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
A = list(accumulate(A))
ind = bisect.bisect_right(A,x)-1
if ind == -1:
    print(0)
elif A[ind] == x:
    print(ind+1)
else:
    print(ind)
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
i = 0
while i<N and x>=A[i]:
    x -= A[i]
    i += 1
if x>0:
    i -= 1
print(i)
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort(key=int)
ans=0
for i in range(n):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ans+=1
if ans==n:
    if (x-sum(a))>0:
        print(ans-1)
    else:
        print(ans)
else:
    print(ans)
n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(n):
    if A[i]<=x:
        cnt += 1
        x -= A[i]
    else:
        break
print(cnt if x==0 else cnt-1)
p_c,k_c=(int(x) for x in input().split())
al=list(map(int,input().split()))
al.sort(reverse=True)
count=0
for i in range(p_c):  
  if i==al.index(al[-1]):
    k_c=k_c-al[i]
    if k_c==0:
      count+=1
    else:
      break
  elif k_c==0 or k_c<0:
    break
  else:
    k_c=k_c-al[i]
    count+=1
print(count)
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
count=0
for i in range(N):
    if x<a[i]:
        break
    else:
        count+=1
        x-=a[i]

print(count)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
for i in range(n):
  if a[i] <= x:
    ans += 1
    x -= a[i]
  else:
    break
if x > 0:
  ans -= 1
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0
count = 0
for i in range(n):
  if x:
  	x -= a[i]
  else:
    print(i)
    exit()
print(n if x == 0 else n-1)
n, x, *aa = map(int, open(0).read().split())

aa.sort()

from itertools import accumulate

print(len([a for a in accumulate(aa) if a<=x]))
n, x = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])

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

A.sort()
Sum = sum(A)
if x >= Sum:
  print(N)
  exit()

ans = 0
for i in range(N):
  if x >= A[i]:
    ans += 1
    x -= A[i]
  else:
    print(ans)
    break
else:
  print(ans)
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 a[i]>x:
            break
        res+=1
        x-=a[i]
    if x!=0 and res!=0:
        res-=1
print(res)
n,x = map(int,input().split())
a = list(map(int,input().split()))

a = sorted(a)
count = 0

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