peterverebics/CodeNet_Python_118 huggingface dataset:
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 or (i == N-1 and rx != a[i]):
    print(c)
    exit()
  c += 1
  rx -= a[i]
print(N)
N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
ans = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
  ans = i
else:
  if cumsum != x:
    ans -= 1
print(ans)
N,x = map(int,input().split())
As = list(map(int,input().split()))
As.sort()
cnt = 0
ans = 0
while x > 0:
    if cnt + 1 == N and x != As[cnt]:
        x = 0
    elif x >= As[cnt]:
        x -= As[cnt]
        ans+=1
    cnt += 1
else:
    print(ans)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0

if sum(a) == x:
    print(n)
    exit()

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

print(ans)
import sys
import collections
import bisect


def main():
    n, x = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    k = 0
    ans = 0
    for i in range(n):
        k += a[i]
        if k > x:
            print(ans)
            return
        ans += 1
    print(ans if sum(a) == x else ans - 1)


if __name__ == '__main__':
    main()
N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a.sort()
ans = 0

for i in a:
    if x >= i:
        ans += 1
        x -= i
    else:
        x = 0
        break
        
if x > 0:
    ans -=1
print(ans)
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]
    else:
        break
if x != 0 and res != 0 and res == n:
    res -= 1
print(res)
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 18

def main():
    N,x = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    ans = 0
    for a in A:
        if x - a >= 0:
            x -= a
            ans += 1
        else:
            x = 0
            break
    if x > 0:
        ans -= 1
    print(ans)
if __name__ == '__main__':
    main()
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== x:
    print(n)
else:
    print(n-1)
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans=0
for i in range(N):
  x = x-a[i]
  if x>=0:
    ans+=1
  else:
    break
if x>0:
  print(ans-1)
else:
  print(ans)
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 range(len(s)):
            if sum(s[:i]) <= x < sum(s[:i+1]):
                print(i)
# Problem A - Candy Distribution Again

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

# initialization
a_list = sorted(a_list)
person_num = 0

# count process
for i in range(len(a_list)):
    a = a_list[i]
    x = x - a
    if x >= 0:
        person_num += 1

# output
if x>0:
    print(person_num - 1)
else:
    print(person_num)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(); b = 0
for i in range(len(a)):
    if x >= a[i]: x -= a[i]; b += 1
    else: break
else:
    if x > 0: b -= 1
print(b)
n, x = map(int, input().split())
li_a = list(map(int, input().split()))

answer = 0
id = -1

for idx, a in enumerate(sorted(li_a)):
    if x >= a:
        answer += 1
        x -= a
        id = idx
    else:
        break
if answer == 0:
    print(answer)
elif x == 0:
    print(answer)
else:
    if id == (n -1):
        print(answer - 1)
    else:
        print(answer)
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

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

if x==A[-1]:
    K+=1

print(K)
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
else:
	if X:
		res = max(0, res-1)

print(res)
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0

for i in a:
    if x > i:
        x -= i
        cnt += 1
    elif x == i:
        cnt += 1
        break
    else:
        break
else:
    cnt -= 1

print(cnt)
import itertools

def main():
    N,x = map(int,input().split())
    a = sorted(list(map(int,input().split())))
    accum_a = list(itertools.accumulate(a))
    ans = 0
    for i in range(N):
        if accum_a[i] > x:
            break
        else:
            ans += 1
    if accum_a[-1] < x:
        ans -= 1
    print(ans)

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

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

if x > 0:
    c -= 1

print(c)
# -*- coding: utf-8 -*-
n, x = map(int,input().split())
a = [int(i) for i in input().split()] 

a.sort()
su = 0
ans = 0
for i in range(n - 1):
    su += a[i]
    if su <= x:
        ans += 1
    if su > x:
        break
if su + a[-1] == x:
    ans += 1
print(ans)
def solve(n, x, A):
    A.sort()
    count = 0
    for i in range(n):
        if i < n - 1 and A[i] <= x or i == n - 1 and A[i] == x:
            x -= A[i]
            count += 1
        else:
            break
    return count

_n, _x = list(map(int, input().split()))
_A = list(map(int, input().split()))
print(solve(_n, _x, _A))
n,x = map(int,input().split())
s = sorted(list(map(int,input().split())))
cnt = 0
for i in range(len(s)):
    if(x - s[i] >= 0 ):
        if(x < s[i] or (i == len(s)-1 and x != s[i])):
            break
        else:
            cnt += 1
        x = x-s[i]
print(cnt)
N,X=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
cnt=0
if sum(A)<X: cnt-=1
for i,a in enumerate(A):
    X-=a
    if X>=0:
        cnt+=1
    else:
        break
print(cnt)
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
cnt=0
while x>0:
    #print(x)
    if x>=A[cnt]:
        x-=A[cnt]
        cnt+=1
    else:
        break
    if len(A)==cnt:
        if x>0:
            cnt-=1
        break
print(cnt)
n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
count = 0
for i in range(n):
    if x >= a[i]:
        count += 1
        x -= a[i]
    else:
        break
if count == n:
    if x != 0:
        count -= 1
print(count)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

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

i = 0

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

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

if x == 0 or ans == 0 or ans < N:
  print(ans)
else:
  print(ans-1)
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(S, x)))
n, x = map(int, input().strip().split())
as_ = map(int, input().strip().split())
as_ = sorted(as_)

cnt = 0
for a in as_:
    if x >= a:
        x -= a
        cnt += 1
    else:
        x = 0
        break

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

print(cnt)
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
SUM = 0
f = 0
for i in range(N):
  SUM += A[i]
  if SUM > x:
    print(i)
    f = 1
    break
if f == 0:
  if SUM == x:
    print(N)
  else:
    print(N-1)
# A - Candy Distribution Again
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
tmp = 0
ans = 0
for a in A:
    tmp += a
    if tmp<=x:
        ans += 1
    else:
        break
if ans==N and tmp!=x:
    ans -= 1
print(ans)
N,x=map(int,input().split())
c=0
for a in sorted(map(int,input().split())):
    x-=a
    if x<0:
        break       
    c+=1
else:
    if x !=0:
        c-=1
print(c)
N, x = map(int, input().split())
a = list(map(int, input().split()))
y = x
a = sorted(a)
ans = 0

for i in a:
    if y >= i:
        ans += 1
        y -= i
    else:
        break

if x > sum(a):
    ans -= 1
print(ans)
n,x = map(int,input().split())
a_inputs = sorted([int(i) for i in input().split()])

ans=0
if sum(a_inputs)<x:
    ans=n-1
else:
    while a_inputs:
        a = a_inputs.pop(0)
        if a<=x:
            x-=a
            ans+=1
        else:
            break
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
acsum = [0]

for i in range(n):
    acsum.append(acsum[i] + a[i])

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

a=sorted(a)

ans= 0

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

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

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

answer = 0
for i in range(N):
    x -= a[i]
    if x < 0:
        break
    answer += 1
    if i == N-1 and x != 0:
        answer -= 1
        break
    if x < a[i]:
        break
print(answer)
from itertools import accumulate
from bisect import bisect
N,x,*A=map(int, open(0).read().split())
B=list(accumulate(sorted(A)))
i=bisect(B, x)
if i==N and sum(A)!=x:
    i=N-1
print(i)
n,x = map(int,input().split())
a = sorted(map(int,input().split()))
c=0
for i in a:
    if x<i:
        break
    x-=i
    c+=1
else:
    if x!=0:
        c-=1
print(c)
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    ret = 0
    cnt = 0
    if sum(A)<X:
        print(N-1)
    elif sum(A)==X:
        print(N)
    else:
        for i in range(N):
            X-=A[i]
            if X<0:
                break
        print(i)

if __name__ == '__main__':
    main()
# coding: utf-8
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) == x:
    print(N)
else:
    c = 0
    for i in a:
        if i > x:
            break
        x -= i
        c += 1
    if c == N:
        print(c - 1)
    else:
        print(c)
n, x=map(int, input().split())
c=list(map(int, input().split()))
c.sort()
ans=0
for i in range(n-1):
  if c[i]<=x:
    x-=c[i]
    ans+=1
  else:
    break
if c[n-1]==x:
  ans+=1

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

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

if x == a[-1]:
    ans += 1
print(ans)
from sys import stdin

n, x = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))

ans = 0
a.sort()
for i, ai in enumerate(a):
    if x < ai:
        break
    if i == n - 1:
        if x > ai:
            break
    x -= ai
    ans += 1

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

kids.sort()
i=0
while i<n and x>=kids[i]:
  x-=kids[i]
  i+=1

if x!=0 and i==n:
  i-=1
if i<0:
  i=0
  
print(i)
n , x = map(int , input().strip().split())
a  = list(map(int , input().strip().split()))
a.sort()
if sum(a) < x:
  count = -1
else:
  count = 0

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

print(count)
N,X,*A=map(int,open(0).read().split())
c=0
for a in sorted(A):
    X-=a
    if X<0:
        break
    c+=1
print(c-(X>0))
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

ans = 0

if X > sum(A):
    print(N-1)
else:
    for i in range(len(A)):
        if X >= A[i]:
            X -= A[i]
            ans += 1
        else:
            break
    print(ans)
# 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
if cnt == n:
    cnt-=1
print(cnt)
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))

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

ans = 0
for i in range(len(a)):
    if not i == len(a)-1:
        if x > a[i]:
            ans += 1
            x = x-a[i]
        elif x == a[i]:
            ans += 1
            break
        else: #x < a[i]
            break
    else:
        if x == a[i]:
            ans += 1
        else:
            pass

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

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

if sum(a) > x:
    while sum(a) > x:
        del a[-1]
    print(len(a))
else:
    print(N) if sum(a) == x else print(N-1)
N,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

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

if sum(A) < x:
    print(N-1)
else:
    A.sort()
    count = 0
    while(x > 0):
        x -= A[count]
        if x >= 0:
            count += 1
    print(count)
    
# 子供が喜ぶお菓子の合計sum(A)が配れるお菓子の数xより大きいか否かで場合分け
# sum(A) < x　のとき子供全員にお菓子は配れるが、余りが発生するので一人は喜ばない
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
ans=0
h=0
for i in range(a):
    if sum(c[0:i+1])>b:
        ans=i
        h=1
        break
    elif sum(c)==b:
        ans=a
        h=1
        break
if h==0:
    ans=a-1
print(ans)
n,x = map(int,input().split())
a = list(map(int,input().split()))

#n,x = 3,30
#a = [20,30,10]

suma = sum(a)

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

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

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

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

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

a.sort()
count = 0

for i in range(len(a)):
    tmp = a[i]

    if x >= tmp and i != len(a) - 1:
        count += 1
        x -= tmp
    else:
        if tmp == x:
            count += 1
        break

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

print(cnt)
n, candy = list(map(int, input().split()))
nums = list(map(int, input().split()))

nums.sort()

ans = 0
for i in range(n):
    if candy >= nums[i]:
        candy -= nums[i]
        ans += 1
    else:
        break

# 配りきってまだ余っている場合
if candy > 0 and ans == n:
    ans -= 1
print(ans)
n , x = map(int,input().split())
a = sorted(list(map(int,input().split())))
cnt = 0
if x > sum(a):
	print(n - 1)
	exit()
    
for i in range(n):
	if (x - a[i]) >= 0:
		x -= a[i]
		cnt += 1
	else:
		break
        
print(cnt)
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

sum = 0
ans = 0
for i in range(len(a)):
    sum += a[i]
    if x >= sum:
        ans += 1
        if ans == N:
            if sum != x:
                ans -= 1
                break
    else:
        break
print(ans)
N,x=map(int,input().split())
a=sorted(map(int,input().split()))
c=0
if x>sum(a):
  print(N-1)
  exit()

while x>0 and c<=N-1:
  if x-a[c]>=0:
    x-=a[c]
    c+=1
  else:
    break


print(c)
n, x = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
cnt = 0
a.sort()
if x > sum_a:
    cnt = n - 1
elif x == sum_a:
    cnt = n
else:
    for i in a:
        if i <= x:
            x -= i
            cnt += 1
        else:
            break
print(cnt)
N, x = map(int, input().split())
tmp = x
A = list(map(int, input().split()))
ans = 0
A.sort()
for a in A:
  if x >= a:
    x -= a
    ans += 1
if tmp > sum(A):
  ans -= 1
print(ans)
from typing import SupportsComplex


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

result = []
for v in a:
    if x >= v:
        result.append(v)
        x -= v
    else:
        break

if len(result) == 0:
    print(0)
    exit()

if (x > 0) and (len(result) == len(a)):
    result[-1] += x

if result[-1] != a[len(result)-1]:
    ans = len(result)-1
else:
    ans = len(result)

print(ans)
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
result = 0
sorted_a = sorted(a)
remain = x
for a_i in sorted_a:
    if remain >= a_i:
        result += 1
        remain -= a_i
    else:
        break

### 最後の子供にぴったりのお菓子をあげられなかった
if result == N and remain != 0:
    result -= 1
print(result)
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
if sum(a) == x:
  ans = n
elif x < min(a):
  ans = 0
else:
  if sum(a) < x:
    ans = n - 1
  else:
    a.sort()
    k = 0
    for e in a:
      k += e
      if k <= x:
        ans += 1
      else:
        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 = sorted(a)
    total = 0
    for i in range(n):
        total += a[i]
        if total == x:
            print(i+1)
            exit()
        elif total > x:
            print(i)
            exit()
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)
import numpy as np
N, x = map(int, input().split())
a = np.array(list(map(int, input().split())))

cs = np.sort(a).cumsum()

if cs[-1]<x:
    print(N-1)
elif cs[-1]==x:
    print(N)
else:
    print(np.where(cs<=x)[0].shape[0])
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)
else:
    print(0)
n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for a in A:
    x = x - a
    if x < 0:
        break
    ans += 1
if x > 0 and ans > 0:
    ans -= 1
print(ans)
N,x = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
a = 0
an = 0
while a < N:
    x -= li[a]
    if x < 0:
        break
    an += 1
    a += 1
if x > 0:
    an -= 1
print(an)
n, x = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
while x-a[c] >= 0:
    x -= a[c]
    c += 1
    if x == 0:
        break
    elif c == n:
        c -= 1
        break
print(c)
import sys
input=sys.stdin.readline
from bisect import bisect_right
import itertools

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

A.sort()
Acum = list(itertools.accumulate(A))
answer = bisect_right(Acum,X)
if answer == N:
    if Acum[-1] < X:
        answer -= 1
print(answer)
N,X=map(int,input().split())
*A,=map(int,input().split())
A.sort()

ans=0
i=0
while X and i<N-1:
    X-=A[i]
    if X>=0:
        ans+=1
    else:
        break
    i+=1

if i==N-1 and A[i]==X:
    ans+=1

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

for i, a in enumerate(A):
    if a > x:
        print(answer)
        exit()
    if i == N-1:
        if a != x:
            print(answer)
        else:
            answer += 1
            print(answer)
    else:
        x -= a
        answer += 1
n, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
A.sort()

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

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

print(counter)
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
count = 0

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

for i in range(N):
    if x >= a[i]:
        x = x - a[i]
        count += 1
    else:
        print(count)
        exit()
if x > 0:
    print(count - 1)
else:
    print(count)