peterverebics/CodeNet_Python_118 huggingface dataset:
N,X = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
m = sum(a)
count = 0
S=0
if m == X:
    print(N)
elif m < X:
    print(N-1)
elif a[0] > X:
    print(0)
else: 
    for i in a:
        if S < X:
            S = S + i
            count = count + 1
    else:
        print(count-1)
N, X = map(int, input().split())
lists = list(map(int, input().split()))
 
if X - sum(lists) > 0:
    print(len(lists) - 1)
    exit()
 
count = 0
for num in sorted(lists):
    X -= num
    if X >= 0:
        count += 1
        if num == lists[-1]:
            break
        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 0 <= x-a[i]:
        x = x-a[i]
        ans +=1
    else:
        break
print(ans)
N, x = map(int, input().split())
a = sorted(map(int, input().split()))

while sum(a) > x and len(a) != 1:
    a.pop(-1)
print(len(a)) if sum(a) == x else print(len(a) - 1)
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 x > 0 and count != 0:
  count -= 1
print(count)
N, x = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])

ans = 0

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

print(ans)
n,x= map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
    if 0 <= x-a[i]:
        x = x-a[i]
        ans +=1
    
print(ans)
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()))
count = 0
#昇順に並べ替える
sort_a = sorted(a)
for i in range(len(a)):
    if x > sort_a[i] and x == sort_a[i]:
        count += 1
        x -= sort_a[i]
        continue
    break
print(count)
# AGC 027: A – Candy Distribution Again
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a.sort()

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

print(answer)
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:
        break

if x != 0:
    count -= 1

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

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

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

print(ans)
n,x = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0
if A[0] > x:
    print(ans)
    exit()

for a in A:
    if a <= x:
        ans += 1
        x -= a
if x > 0: ans -= 1
print(ans)
n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
print(a)
count = 0
for i in a:
    print(f"{i},{x}")
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
print(count)
if x != 0:
    count -= 1 if count == n else 0
print(count)
n,x = map(int,input().split())

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

ans = 1

s.sort()

if sum(s)==x:
    print(n)
elif sum(s)<x:
    print(n-1)
else:
    if s[0]>x:
        print(0)
    else:
        for i in s:
            x -= i
            if x<=0:
                break
            else:
                ans += 1
        print(ans)
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+1)
        exit()
print(N)
n,x=map(int,input().split())
a=sorted([int(i)for i in input().split()])
isHappy=[False for i in range(n)]
res=0
for i in range(n):
    if x>=a[i]:
        isHappy[i]=True
        x-=a[i]
    else:
        break
res=isHappy.count(True)
if x != 0:res-=1
print(max(0,res))
n,x=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

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

a = sorted(a, reverse = False)

count = 0
if sum(a) < x:
    count = N -1
else:
    for i in a:
        x -= i
        if x < 0:
            count -=1
            break
        elif x == 0:
            count += 1
            break
        count+=1
if count < 0:
    count = 0
print(count)
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:
    print(cnt+1)
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1
# 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 + 1):
    s = sum(nums[:i])
    if s == x:
        ans = max(ans, i)
    elif s < x:
        ans = max(ans, i - 1)
print(ans)

# なんか連続するこどもになっていた
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,x=nii()
a=lnii()
a.sort()

a_sum=0
for i in range(n):
  a_sum+=a[i]
  if a_sum>x:
    print(i)
    exit()

print(n)
N,x=input().split()
X=int(x)
n=int(N)
y=0
A = [int(i) for i in input().split()]
A.sort()
for z in range(n):
  y+=A[z]
  if y>=X:
    break
    print(z+1)
else:
  print(n-1)
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

if x != 0:
    cont -= 1

print(cont)
n, x = map(int,input().split())
children = list(map(int,input().split())) 
children.sort()
count=0
c = 0
if x < children[0]:
  print(0)
  exit()
for i in range(n):
  count += children[i]
  c += 1
  if count >= x:
    print(c)
    exit()

print(n-1)
n,x = tuple(map(int,input().split()))
a = tuple(map(int,input().split()))
a = sorted(a)
ans=0

for a_i in a:
  x -= a_i
  if x<0:
    break
  else:
    ans+=1
  
print(ans)
n,x=map(int,input().split())
l=sorted(list(map(int,input().split())))
if sum(l)>x:print(n-1);exit()
d=[]
now=0
for i in l:
    now+=i;d.append(now)
from bisect import bisect_left as bl,bisect_right as br

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

A.sort()
ans = []
for i in A:
	ans.append(i)
	x -= i
	#print(ans, x)
	if x <= 0:
		break
if x > 0:
	print(len(ans)-1)
else:
	print(len(ans))
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
X = x
for A in a:
    if x < A:
        break
    x -= A
    ans += 1
if sum(a)!=X:
    ans = ans - 1
print(ans)
n, x = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
ans = 0
for consume_v in arr:
    if x >= consume_v:
        x -= consume_v
        ans += 1
    elif x > 0 and ans > 0:
        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 A[i] <= x:
        count += 1
        x -= A[i]
print(count)
N,x = map(int,input().split())
a = list(map(int,input().split()))

a = sorted(a, reverse = False)

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

if a_sum== sum(A):
    print(n)
else:
    print(n-1)
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
    
    if x > 0 and res != 0:
        print(res - 1)
    else:
        print(res)

if __name__ == '__main__':
    main()
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
S = [0]
for i in range(N):
    S.append(S[i] + A[i])
# print(S)
l = -1
r = N+1
while r - l > 1:
    m = l + (r-l)//2
    if S[m] > x:
        r = m
    else:
        l = m
print(l - (S[l] != x))
n, x = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
ans = 0

for i in arr:
    x -= i
    if x < 0:
        break
    else:
        ans += 1
    if x > 0 and ans > 0:
        ans -= 1

print(ans)
import itertools
import bisect
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cumsum = list(itertools.accumulate(A))
ans = bisect.bisect_right(cumsum,x)
print(ans)
N, x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
i=0
while i<N and x>=a[i]:
  x-=a[i]
  i+=1
if x>0 and i>0:
  i-=1
print(i)
N,x=map(int,input().split())
C=sorted(list(map(int,input().split())))
num=0
if sum(C)==x:
    print(N)
    exit()
elif sum(C)>x:
    print(N-1)
    exit()
for i in range(N):
    if C[i]>x:
        print(i)
        exit()
    else:
        x-=C[i]
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-1)
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
if r > 0 and count > 0:
    count -= 1
print(count)
n, x = map(int, input().split())
res = 0
dat = list(map(int, input().split()))
dat.sort()
for i in range(n):
    if x >= dat[i]:
        res += 1
        x -= dat[i]
if x > 0 and res != 0:
    res -= 1
print(res)
N,x=map(int,input().split())
a=sorted(map(int,input().split()))
c=0
while x>0 and c<=N-1:
  if x-a[c]>=0:
    x-=a[c]
    c+=1
  else:
    break


if x>0 and c>0:
  c-=1

print(c)
# agc027_a.py
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
    exit()

a.sort()
cnt = 0
for i in a:
    if x>=i:
        cnt += 1
        x -= i
print(cnt-1)
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:
    if count == 0:
        print(0)
    else:
        print(count-1)
import sys
input = sys.stdin.readline

N,X=map(int,input().split())
vA=list(map(int,input().split()))
vA.sort()

res=0
for a in vA:
	if a<=X:
		res += 1
		X -= a
	else:
		break
if X:
	res = max(0, res-1)

print(res)
import math
import sys

n, x = map(int, input().split())
a = [int(val) for val in input().split()]

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

if x == a[n-1]:
    ans += 1


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:
        x-=a[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 sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<=x:
        s+=a[i]
        i+=1

print(s)
print(i-1)
n,x=map(int,input().split())
A=sorted(list(map(int,input().split())))
num=0
for i in range(n):
    if x<A[i]:
        print(i)
        break
else:print(n)
N , X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A = [0] + A
for i in range(N):
  A[i+1] = A[i]+A[i+1]
  if A[i+1]>X:
    break
print(i)
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

if x != 0:
    count -= 1

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 -= a[i]
        ans += 1
if x != 0:
    ans = max(0, ans - 1)
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

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

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

print(ans - (S != x))
from itertools import accumulate
from bisect import bisect_right

N, x, *A = map(int, open(0).read().split())

A.sort()
S = list(accumulate(A))

if S[-1] == x:
    print(N)
else:
    print(min(N - 1, bisect_right(A, x)))
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:
    break

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

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

a.sort()

s = 0
counter = 0

for i in range(N):
    if i != N-1:
        if s < x:
            s += a[i]
            counter += 1
        else:
            break
    else:
        if x - s == a[i]:
            counter += 1
        else:
            break

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

#print(N, x)
A.sort()
#print(A)

cnt = 0
for a in A:
  if x >= a:
    x -= a
    cnt += 1
  else:
    break
      
print(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 + 1):
    s = sum(nums[:i])
    if s <= x:
        ans = max(ans, i)
print(ans)
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=-1
num=0
for i in range(n):
    num+=a[i]
    if num>x:
        ans=i
        break
if ans==-1:
    print(n)
else:
    print(ans)
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,x = LI()
a = LI()
ans = 0
a.sort()
for y in a:
    if x>=y:
        x -= y
        ans += 1
    else:
        break
print(ans)
from bisect import bisect_left
from itertools import accumulate


N, x = map(int, input().split())
a = list(accumulate(sorted(map(int, input().split()))))
if x in a:
    print(bisect_left(a, x) + 1)
else:
    print(bisect_left(a, x) - 1)
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
S = [0]
for i in range(N):
    S.append(S[i] + A[i])
# print(S)
l = -1
r = N+1
while r - l > 1:
    m = l + (r-l)//2
    if S[m] > x:
        r = m
    else:
        l = m
print(l if S[l] == x else max(0, l-1))
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:
    ans -= 1
print(max(0,ans))
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)
        exit()
print(n)
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
    
print(ans)
n, x = map(int, input().split())
a = [int(_) for _ in input().split()]
a.sort()
ans = 0
for i in a:
    if x < i:
        break
    x -= i
    ans += 1
if x > 0 and ans != 0:
    ans -= 1
print(ans)
N, x = map(int, input().split())
a_li = list(map(int, input().split()))
a_li.sort()
ans = 0
for a in a_li :
    if x >= a :
        ans += 1
        x -= a
    else :
        break
if x != 0 :
    ans -= 1
print(max(0, ans))
n, x = map(int, input().split())

nums = sorted(list(map(int, input().split())))

count = 0
for i, num in enumerate(nums):
    if num <= x:
        if i != nums.index(num):
            count += 1
            x -= num
        else:
            if num == x:
                count += 1
                x -= num
    else:
        break

print(count)
from bisect import bisect_left
from itertools import accumulate


N, x = map(int, input().split())
a = list(accumulate(sorted(map(int, input().split()))))
if x in a:
    print(bisect_left(a, x) + 1)
else:
    print(max(0, bisect_left(a, x) - 1))
#22
N,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

if sum(a) ==x:
    print(N)
else:
    for i in range(N):
        if sum(a[0:i+1]) >x:
            print(i)
            break
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]:
                cnt+=1
                X=0
if X>0 and cnt>0:
    cnt-=1
print(cnt)
n, k =map(int,input().split())
data = list(map(int,input().split()))
data = sorted(data)
cnt = 0
for var in data:
    if var < k:
        cnt += 1
        k = k-var
       
    else:
        continue
print(cnt)
n,x=map(int,input().split())
l=sorted(list(map(int,input().split())))
d=[]
now=0
for i in l:
    now+=i;d.append(now)
from bisect import bisect_left as bl,bisect_right as br

print(max(0,br(d,x)-1+(sum(l)==x)))
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
rx = x
for i in range(N):
  if a[i] > rx:
    print(c)
    exit()
print(N)
import sys
N, x = map(int, input().split())
a = sorted(map(int, input().split()))

ans = 0
score_x  = x

for  i in range(N):
    if score_x < a[i]:
        print(0)
        sys.exit()

    elif score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1

print(ans)
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 and x!=0:
    print(count)
else:
    print(n-1)
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
A.sort()
for a in A:
  if x >= a:
    x -= a
    ans += 1
print(ans)
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]
    print(k+1)
N, x = [int(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ")]
 
lst.sort()
cnt = 0
 
for i in range(0,N):
  if x >= lst[i]:
    x -= lst[i]
    cnt += 1
  else:
    break
    
print(cnt)
from itertools import accumulate
from bisect import bisect_right

N, x, *A = map(int, open(0).read().split())

A.sort()
S = list(accumulate(A))

if S[-1] == x:
    print(N)
else:
    k = bisect_right(A, x)
    print(N - 1 if k == N else k)
n,x = map(int,input().split())
line = sorted(list(map(int,input().split())))
count = 0
if sum(line) < x:
  count = n - 1
elif sum(line) == x:
  count = n
else:
  for i in range(n):
    left = x - line[i]
    if left > 0:
      count += 1
    else:
      break
print(count)
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)
else:
    print(ind+1)
def myAnswer(N:int,x:int,A:list) -> int:
   if(sum(A)==x): return N
   A.sort()
   counter = 0
   for n,a in enumerate(A):
      if(a <= x):
         x -= a
         counter += 1
      else:
         break
   if(x != 0 and counter != 0 ):
      counter -=1
   return counter

def modelAnswer():
   tmp=1
def main():
   N,x = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,x,A[:]))


if __name__ == '__main__':
   main()
def candy(arr, n, x):
	if sum(arr) == x:
		return n
	best = 0
	j = 0
	while(j < n):
		c = 0
		for i in range(j, n-1):
			if arr[i] < x:
				c += 1
				x -= arr[i]
			elif arr[i] == x:
				c += 1
				break
		best = max(best, c)
		j += 1
	if arr[n-1] == x:
		best += 1
	return best
n, x = map(int, input().split())
arr = list(map(int, input().split()))
print(candy(arr, n, x))
# 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 >=0:
        X-=a
        cnt+=1
print(cnt)
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

count = 0

for v in a:
    if v <= x and x >= 0:
        count +=1
        x -= v
        
if x != 0:
    count = count - 1

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

child = 0
candy = 0

print(a)

for i in a:
    candy += i
    if candy <= x:
        child += 1

if sum(a) < x:
    child -= 1

print(int(child))
n,x = map(int,input().split())
a = sorted(map(int,input().split()))
c=0
for i in a:
    if i<=x:
        x-=i
        c+=1
else:
    if x>0:
        c-=1
print(c)
N, x = map(int, input().split())
a = sorted(map(int, input().split()))

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

arr.sort()
ans = 0

for (i, v) in enumerate(arr):
    if x >= v:
        x -= v
        ans += 1

    if i == len(arr) - 1 and x > 0:
        if not ans == 0:
            ans -= 1
        break
print(ans)
N,x=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)==x:
  print(N)
  exit()
else:
  a.sort()
  ans=0
  flag=False
  i=0
  while i<N:
    if x-a[i]>=0:
      flag=True
      x=x-a[i]
      ans+=1
    i+=1
if flag==False:
  print(0)
  exit()
print(ans if x==0 else ans-1)
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 = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    if x - i < 0:
        break
    elif i == children[N - 1] and x - i > 0:
        print(N - 1)
    else:
        x -= i
        cnt += 1

print(cnt)
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
if sum(l) <= x:
    print(n)
else:
    for i in range(n):
        print(x)
        if x <= 0:
            break
        x -= l[i]
    print(i+1)
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 X >0 :
    ans -=1     
       
    
print(ans)
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]:
    cnt += 1
  else:
    break
    
print(cnt)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
i = 0
while True:
    x -= a.pop()
    ans += 1
    i += 1
    if x == 0:
        break
    elif len(a) == 0 or i == n:
        ans -= 1
        break
print(ans)
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
      
count=0
for i in range(N):
  if x>=a[i]:
  	x=x-a[i]
  	count+=1
  
print(count)
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0

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

if x != 0:
    ans -= 1


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

num_lists.sort()
cnt = 0
for i in num_lists:
    if i <= x:
        cnt += 1
        x -= i
    else:
        break

if num_lists[0] <= x:
    cnt -= 1

print(cnt)
n,x=map(int,input().split())
ans=0
a=sorted(list(map(int,input().split())))
for i in range(n):
    x-=a[i]
    if 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)
      exit()
print(n)