peterverebics/CodeNet_Python_118 huggingface dataset:
N, x = map(int, input().split())
a = list(map(int, input().split()))
sort_a = sorted(a)
count = 0
for y in range(len(sort_a)):
    if y != len(sort_a) - 1:
        if sort_a[y] <= x:
            x -= sort_a[y]
            count += 1
        else:
            break
    else:
        if sort_a[y] == x:
            count += 1

print(count)
N, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
children = [0] * N
a.sort()
kashi = 0
n = N
if a[0] > x:
    print(0)
elif sum(a) == x:
    print(N)
else:
    for i in range(0,n):
        if kashi > x:
            break        
        kashi += a[i]
        children[i] += 1
#     print(kashi)
    if kashi == x :
        print(N - children.count(0))
    else:
        print(N - children.count(0) - 1)
import sys
input = sys.stdin.readline

# A - Candy Distribution Again
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
candies = 0
ans = 0

for ai in a:
	if candies < x:
		candies += ai
		ans += 1
	else:
		break

if candies != x:
	ans -= 1

print(ans)
n, y = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
if y == sum(a):
  ans = n
elif y > sum(a):
  ans = n -1
else:
  for i in range(n):
    if y - a[i] >= 0:
      y -= a[i]
      ans += 1
    else:
      break
print(ans)
# coding: utf-8

def main():
    _, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()

    ans = 0

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

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

    print(ans)

if __name__ == "__main__":
    main()
_, x, *a = map(int, open(0).read().split())
c = 0
for i in sorted(a):
  x -= i
  if x<0:
    break
  c += 1
print(c - (x>0))
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in range(N):
    if x>=a[i]:
        count += 1
        x -= a[i]
    else:
        break
if (x!=0)and(count==N):
    count -= 1
print(count)
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
n = 0

if x > sum(a):
    print(N-1)
    exit()

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

for i in range(N):
    x = x - a_list[i]
    if x < 0:
        break
if i == N-1 and x == 0:
    i += 1

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

for i in a[:-1]:
    if i <= x:
        ans += 1
        x -= i
    else:
        break
        
if x == a[-1]:
    ans += 1
    
print(ans)
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)
#S= str(input())
#T= str(input())
N,X = map(int,input().split())
#N = int(input())
A = list(map(int,input().split()))
c=0
while X>=min(A):
    if len(A)==1:
        if X==A[0]:
            c+=1
            print(c)
            exit()
        else:
            print(c)
            exit()

    if X>=min(A):
        X-=min(A)
        A.remove(min(A))
        c+=1

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


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

arr.sort()
ans = 0

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

if arr[-1] == x:
    ans += 1

print(ans)
#Candy Distribution Again
n,x = map(int, input().split())
s= list(map(int,input().split()))

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

if x > sum(a):
  print(n - 1)
else:
  c = 0
  while x >= a[-1]:
    x -= a.pop()
    c += 1
    if c == n:
      break
  print(c)
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
if sum(a) < x:
    print(n-1)
    exit()
for i in range(n):
    if x>=a[i]:
        cnt+=1
        x-=a[i]
    else:
        break
print(cnt)
n,x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
cnt=0
for i,X in enumerate(a):
    if x>=X:
        cnt+=1
        x-=X
    else:
        break
if cnt==n and x>0:
    cnt-=1
print(cnt)
N, x = input().split(' ')
N = int(N)
x = int(x)
a = input().split(' ')
a = [int(a[i]) for i in range(N)]
a = sorted(a)
count = 0
for i in range(N):
  if x - a[i] < 0:
    x -= a[i]
    break
  else:
    x -= a[i]
    count += 1
if x > 0:
  count -= 1

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

s = 0
cnt = 0
for i in a:
    s += i
    if s > x:
        break
    cnt += 1

if s < x:
    cnt -= 1    
print(cnt)
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
    if x>=a[i]:
        ans+=1
        x-=a[i]
    else:
        break
if ans == n:
    if x!=0:
        ans-=1
print(ans)
def last_alert(list_):
    iter_ = iter(list_)
    n = next(iter_)
    for i in iter_:
        yield n, False
        n = i
    yield n, True


N, X = map(int, input().split())
ans = 0
for i, is_last in last_alert(sorted(map(int, input().split()))):
    if is_last and X != i:
        break
    elif X < i:
        break
    X -= i
    ans += 1
print(ans)
# AGC 027 A - Candy Distribution Again
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            count += 1
        else:
            break
    elif x >= a[i]:
        x -= a[i]
        count += 1
    else:
        break
        
print(count)
def resolve():
    import sys
    n,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.sort()
    cnt=0
    for i in range(n):
        if l[i]<=x:
            x-=l[i]
            cnt+=1
        else:
            break
    if cnt==n and x>0:
        cnt-=1
    print(cnt)
resolve()
n, x = [int(w) for w in input().split()]
a_li = [int(w) for w in input().split()]
a_li.sort()

ans = 0
for a in a_li:
    x -= a
    if x >= 0:
        ans += 1
    else:
        break

if x == 0:
    pass
else:
    if x > 0:
        ans = max(ans - 1, 0)

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

a.sort()

cnt = 0
for val in a[:-1]:
    x -= val
    if x < 0:
        break
    cnt += 1
if x == a[-1]:
    cnt += 1
print(cnt)
n,k = map(int,input().split())
L = list(map(int,input().split()))
L.sort()

sum1 = 0
cnt = 0
if k < L[0]:
    print(0)
    exit()
for i in range(n):
    sum1 +=L[i]
    if sum1 <=k:
        cnt +=1
        if i == n-1 and sum1 != k:
            cnt -=1
    else:
        break
print(cnt)
N,x=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
cnt=0
for i in range(N):
    if sum(a)==x:
        cnt=N
    elif sum(a)>x:
        if x>=a[i]:
            x-=a[i]
            cnt+=1
        else:
            break
    else:
        cnt=N-1

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

a.sort()

cnt = 0
for i in range(n):
    if i == n - 1:
        if x == a[i]:
            cnt += 1
    elif x >= a[i]:
        x -= a[i]
        cnt += 1
print(cnt)
n, x = map(int, input().split())
a = list(map(int, input().split()))
c = 0
a_sorted = sorted(a)

for i in range(n):
    x -= a_sorted[i]
    if x > 0 and i <= n-2:
        c += 1
    elif x == 0:
        c += 1
    else:
        break

print(c)
from itertools import accumulate
import bisect
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = list(accumulate(a))
ans = bisect.bisect_right(c, x)
if not ans:
  print(ans)
else:
  print(ans if c[N - 1] >= x else ans - 1)
N,x=map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
for i in a:
    if x >= i:
        x -= i
        cnt +=1
    else:
        print(cnt)
        exit()
if x ==0:
    print(cnt)
else:
    print(cnt-1)
N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < X:
    print(index-1)
else:
    print(index)
n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-1):
    if l[i] <= x:
        x -= l[i]
        ans += 1
else:
    if l[-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 range(n):
    if x>=a[i]:
        x-=a[i]
        ans+=1
    else:
        break
else:
    if x>0:
        ans-=1
print(ans)
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

if cnt == N and x > 0:
  cnt = cnt - 1
print(cnt)
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
happy=0
for i in range(N-1):
    if a[i]<=x:
        x-=a[i]
        happy+=1
    else:
        break
if a[N-1]==x:
    happy+=1
print(happy)
import numpy as np
N, x = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
cumsum = A.cumsum()

if cumsum[-1] < x:
    print(N - 1)
    exit()

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

A.sort()

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

print(cnt)
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):
        print(i)
        break
else:
    if (x != 0):
        print(n - 1)
    else:
        print(n)
#coding:utf-8
n, x = map(int, input().split())
a = list(map(int, input().split()))
child = sorted(a)

for i in range(n):
    x -= child[i]
    if x < 0:
        break
    elif x == 0:
        print(i+1)
        exit()

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

A = sorted(a)

for i in range(N):
    maxcandy += A[i]

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

if maxcandy < X:
    print(count-1)
else:
    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.sort()
cnt=0
if sum(a)==x:
    print(n)
    exit()
else:
    for i in range(n-1):
        if a[i]<=x:
            x-=a[i]
            cnt+=1
print(cnt)
N,x=map(int,input().split())
a=list(map(int,input().split()))

a.sort()

Q=0
for i in range(N):
    if x>=a[i] and i!=N-1:
        Q+=1
        x=x-a[i]
    elif i==N-1 and x==a[i]:
        Q+=1
print(Q)
N, X = map(int,input().split())
S = map(int,input().split())
S = sorted(S)
cnt = 0

for s in S:
  X -= s
  if X >= 0:
    cnt += 1
  else:
    break

if X > 0:
  cnt -= 1
    
print(cnt)
from sys import stdin

n, x = [int(x) for x in stdin.readline().split()]
a_lst = sorted([int(x) for x in stdin.readline().split()])
s = 0

for i, a in enumerate(a_lst):
  s += a
  if s > x:
    print(i)
    exit()
    
if s == x: print(i+1)
else: print(i)
#!/usr/bin/env python3


def main():
    N, x, *A = map(int, open(0).read().split())
    A.sort()
    for i in range(N):
        x -= A[i]
        if x == 0:
            print(i + 1)
            break
        elif x < 0:
            print(i)
            break
    else:
        # ちょうどN個もらわないと喜べない悲しい子どもたち
        print(N - 1)


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

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

if (x > 0):
    print(count - 1)
elif(x == 0):
    print(count)
elif(x < 0):
    print(count - 1)
N,x = map(int,input().split())
a = sorted(map(int,input().split()),reverse=False)
ans = 0

if x > sum(a):
    print(N - 1)

else:
    for i in a:
        x -= i
        if x >= 0:
            ans += 1
    print(ans)
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
i=0
total=0
while True:
    if b<c[i]:
        print(total)
        break
    elif i==a-1:
        if b==c[i]:
            print(total+1)
        else:
            print(total)
        break
    else:
        total+=1
        b=b-c[i]
        i+=1
n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
for i in a:
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
if x != 0:
    count -= 1 if count == n else 0
print(count)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in range(n):
    if x>=a[i]:
        count += 1
        x -= a[i]
    else:
        break
if (x!=0)and(count==n):
    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 i != N-1 and a[i] <= x:
    ans += 1
    x -= a[i]
  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_1=sorted(A)
num=0
total=0
if A_1[0]>x:
    num=0
elif sum(A_1)>=x:
    for i in range(N):
        total+=A_1[i]
        if total==x:
            num+=1
            break
        elif total>x:
            break
        else:
            num+=1

else:
    num=N-1
print(num)
N,X= map(int,input().split())
A = [int(a) for a in input().split()]
A.sort()

tmp = 0
ans = 0

for a in A:
    tmp+=a
    if tmp<=X:
        ans+=1
if ans==N and tmp<X:
    ans-=1
print(ans)
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

child = 0
candy = 0

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 = list(map(int, input().split()))
a.sort()
cnt = 0
while a[cnt] <= x:
    x = x - a[cnt]
    cnt += 1
    if cnt >= len(a):
        break
if x > 0 and len(a) == cnt:
    cnt -= 1
print(cnt)
n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
for i in range(n):
  x = x-a[i]
  if x<0:
    break
if i == n-1 and x == 0:
  i += 1
print(i)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in a:
    x -= i
    if x < 0: break
    else: ans += 1
if ans == n and x != 0: print(ans-1)
else: print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) == x:
  print(n)
elif sum(a) < x:
  print(n-1)
else:
  total = 0
  for i in range(n):
    total += a[i]
    if total == x:
      print(i+1)
      break
    elif total > x:
      print(i)
      break
n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
cnt = 0
for i in range(n):
    x -= a[i]
    if x >= 0:
        cnt += 1
if x > 0:
    print(cnt-1)
else:
    print(cnt)
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(n):
  if a[i]>x:
    print(i)
    exit()
  x-=a[i]
if x==0:
  print(n)
else:
  print(n-1)
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

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

print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = 0
c = 0
for i in range(n):
	s += a[i]
	if s <= x:
		if i == n-1:
			if s == x:
				c += 1
		else:
			c += 1
	else:
		break
print (c)
# AGC 027: A – Candy Distribution Again
N, x = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

a.sort()
distributed = 0
beGlads = 0

for i in range(N):
    if distributed + a[i] > x:
        break
    else:
        distributed += a[i]
        beGlads += 1

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


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


print(i)
# -*- coding: utf-8 -*-

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

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

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

a.sort()
ans = 0
frag = True
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        ans += 1
    else:
        frag = False

if frag and x > 0:
    print(ans-1)
else:
    print(ans)
n,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = [0] * (n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
 
ans = 0
for i in range(n):
    if x >= s[i+1]:
        ans = i+1
if x > s[n]:
    ans -= 1
print(ans)
def resolve():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    okashi = 0
    for i in range(N):
        okashi += a[i]
        if okashi > x:
            ans = i
            break
        elif okashi == x:
            ans = i+1
            break
    else:
        ans = N-1
    print(ans)
resolve()
n,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
if sum(a) < x:
    print(n-1)
elif sum(a) == x:
    print(n)
else:
    for i in a:
        if x >= i:
            cnt += 1
            x -= i
    print(cnt)
import math
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 and x >= a[i] or i == N - 1 and x == a[i]:
        ans += 1
        x -= a[i]
print(ans)
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in a:
    if x >= 0:
        x -= i
        ans += 1
    else:
        break
if x > 0:
    ans -= 1
if x < 0:
    ans -= 1
print(ans)
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
happy_kid = 0
for i in range(N):
    x = x - a[i]
    if i == N - 1:
        if 0 == x:
            happy_kid += 1
    elif x >= 0:
        happy_kid += 1
    else:
        break
print(happy_kid)
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]:
        if i == n-1:
            if a[i] == x:ans+=1
        else:
            x -= a[i]
            ans +=1
    else:break
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
happy = 0
for i in range(n-1):
  if a[i] <= x:
    x -= a[i]
    happy += 1
  else:
    break
happy += 1 if x == a[n - 1] else 0
print(happy)
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)
n,x=map(int,input().split())
A=sorted(list(map(int,input().split())))
for i in range(n):
    if x-A[i]>=0:
        x=x-A[i]
    else:
        print(i)
        exit()
if x==0:print(n)
else:print(n-1)
n,x = map(int,input().split())
a_lst = sorted(list(map(int,input().split())))

cnt = 0

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

#%%
ans = 0
a_list.sort()

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

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

print(ans)
import numpy as np
n,x = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
res = np.cumsum(li)
cnt=0
if res[-1] == x:
    cnt = len(res)
elif res[-1] > x:
    for i in res:
        if i <= x:
            cnt += 1
        else:
            break
else:
    cnt = len(res) -1
print(cnt)
n, x = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])

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