peterverebics/CodeNet_Python_118 huggingface dataset:
from itertools import accumulate
from bisect import bisect_right


def main():
    children, cookies = map(int, input().split())
    target = sorted(list(map(int, input().split())))
    sum_target = sum(target)
    if sum_target < cookies:
        print(children - 1)
    elif cookies < target[0]:
        print(0)
    else:
        accumulate_target = list(accumulate(target))
        print(bisect_right(accumulate_target, cookies))


if __name__ == '__main__':
    main()
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
res = 0
for i, a in enumerate(A):
    x -= a
    if x >= 0:
        res += 1
    else:
        break
else:
    if x > 0:
        res -= 1
print(res)
N, x = map(int, input().split())
sweets = list(map(int, input().split()))

if x == sum(sweets):
    print(N)
else:
    # 少ないものから順に取っていく
    sweets.remove(max(sweets))
    ans = N - 1
    while True:
        if x >= sum(sweets):
            print(ans)
            break

        sweets.remove(max(sweets))
        ans -= 1
from itertools import accumulate
from operator import add

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

if sum(A) == x:
    print(N)
else:
    t = len(list(filter(lambda y: y <= x, accumulate(A, func=add))))
    if t == N:
        print(N - 1)
    else:
        print(t)
N,x = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
c = 0
for i in range(N):
    x -= A[i]
    if x >= 0:
        c += 1
    if x <= 0:
        print(c)
        break
else:
    print(N - 1)
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
sum = 0
ans = 0
for i,a in enumerate(A):
    sum += a

    if sum == x:
        ans = i + 1
        break
    elif sum > x:
        break
    elif i + 1 == N and sum < x:
        ans = i
        break
    ans = i + 1


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

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

if cnt==N and x > 0:
    cnt -= 1
print(cnt)
N, x = map(int, input().split())
a = [int(a) for a in input().split()]

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

sort_a = sorted(a)
count = 0
for i in range(1,N+1):
    if sum(sort_a[:i]) <= x:
        if i < N:
            count += 1
        else:
            pass
    else:
        break

print(count)
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 - (l == N and S[l] < x))
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
S = 0
ans = 0
for i in range(N):
  S += A[i]
  if S <= X:
    ans += 1
  else:
    break
if S < X:
  ans = N-1
print(ans)
#CandyDistributionAgain
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
if x == sum(a):
  ans = n
elif x > sum(a):
  ans = n -1
else:
  for i in range(n):
    if x - a[i] >= 0:
      x -= a[i]
      ans += 1
    else:
      break
print(ans)
n, x = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort()
ans = 0
for a in aaa:
    if x < a:
        break
    ans += 1
    x -= a
else:
    if x > 0:
        ans -= 1
print(ans)
import sys
N, x = map(int, input().split())
a = sorted(map(int, input().split()))


ans = 0
score_x  = x

if score_x < a[0]:
    print(0)
    sys.exit()
    
for  i in range(N):
    if i == (N-1):
        if a[i] == score_x:
            ans = ans + 1
            score_x = (score_x - a[i])
        else:
            break      
    if score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1


print(ans)
import sys
import copy
a = [int(c) for c in input().split()]
N=a[0]
x=a[1]
a = [int(c) for c in input().split()]
a.sort()
for i in range(N):
    x-=a[i]
    if x<0:
        print(i)
        sys.exit(0)
    elif x==0:
        print(i+1)
        sys.exit(0)

print(N-1)
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()
  elif count > x:
    print(c-1)
    exit()

print(n-1)
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
if(count == N and x != 0):
  count -= 1
print(str(count))
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-1):
  if x >= lst[i]:
    x -= lst[i]
    cnt += 1
  else:
    break

    
print(cnt+(x==lst[N-1]))
import sys
N, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
    print(N)
    sys.exit()
else:
    a.sort()
    ans = 0
    for i in range(N-1):
        if a[i] <= x:
            ans += 1
            x -= a[i]
        else:
            print(ans)
            break
    else:
        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:
    if num==x:
        print(n)
    else:
        print(n-1)
else:
    print(ans)
def solve():
  N, x = map(int, input().split())
  A = list(map(int, input().split()))
  A.sort()
  ans = 0
  for i in range(N):
    if i==N-1:
      if A[i]==x:
        ans += 1
      continue
    if x>=A[i]:
      ans += 1
      x -= A[i]
  return ans
print(solve())
N, x = map(int, input().split())
child_list = list(map(int, input().split()))

count = 0
for i, child in enumerate(sorted(child_list)):
  x -= child
  if x < 0:
    break
  if (i == len(child_list) - 1) and x != 0:
    break
  count += 1

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

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

for i, v in enumerate(a):
    x -= v
    if x < 0:
        ans = i
        break
    if x == 0:
        ans = i + 1
        break
    if i == N - 1: 
        ans = i + 1
if x > 0:
    ans -= 1
print(ans)
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()
import itertools
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = list(itertools.accumulate(a))
cnt = 0
for i in range(n):
    if i==n-1 and a[-1]!=x:
        pass
    elif a[i]<=x:
        cnt+=1
print(cnt)
N, x = map(int,input().split())

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

al.sort()

cnt = 0

for a in al[:N-1]:
  if x >= a:
    x -= a
    cnt += 1
  else:
    break
if al[-1] == x:
  cnt += 1

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

if x==0:
    print(ans)
else:
    print(ans-1)
N,x=map(int,input().split())
a=list(map(int,input().split()))
man=[0]*N
a.sort()
ans=0
for i in range(N):
    if a[i]<=x:
        x-=a[i]
        a[i]=0
        ans+=1
    else:
        break
if ans==N:
    if x!=0:
        ans-=1
if ans<0:
    ans=0
print(ans)
N, x = map(int, input().split())
L = list(map(int,input().split()))
L_sorted = sorted(L, reverse=False)

remain = x
ans = 0
for j in range(N):
    if remain>= L_sorted[j] and j != N-1:
        remain = remain - L_sorted[j]
        ans += 1
    
    if j == N-1 and L_sorted[j] == remain:
        ans += 1
print(ans)
n,x = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
A.sort()
i = 0
while i < n:
    if x > A[i]:
        x = x - A[i]
        i += 1
    elif x == A[i]:
        x = 0
        i += 1
        break
    else:
        break
if i == n and x > 0:
    print(i-1)
else:
    print(i)
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
a.sort()
count=0
if sum(a)==x:
  count=N
elif sum(a)<x:
  count=N-1
else:
  for i in range(N):
    if sum(a[:i])<=x and sum(a[:i+1])>x:
      count=i
print(count)
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:
    if y==X:
      print(z+1)
    else:
      print(z)
    break
else:
  print(n-1)
n, x = map(int, input().split())
ls = list(map(int, input().split()))

ans = 0
m = x

ls.sort()

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

if m > sum(ls):
    print(ans - 1)
else:
    print(ans)
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
snack_sum = 0

while ans < N:
    snack_sum += a[ans]
    if snack_sum > x:
        break
    else:
        ans += 1

if ans == N:
    if snack_sum != x:
        print(ans - 1)
        exit()
print(ans)
N, x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
count = 0
for i in range(N):
    x = x - a[i]
    if x < 0:
        break
    count += 1  
if x > 0:
    count -= 1
print(count)
import numpy as np
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = np.sort(np.array(a))
cumul = np.cumsum(a)
sign = np.sign(cumul - x)

if np.all(sign == -1):
    print(N - 1)
else:
    print(np.sum(sign <= 0))
n, x = map(int, input().split())
a = [int(an) for an in input().split()]
a.sort()
ans = 0
num_candy = 0
for an in a:
  num_candy += an
  if num_candy <= x:
    ans += 1
if num_candy < x:
  ans -= 1
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = [0]*n
if (sum(a) == x):
    print(n)
else:
    for i in range(n):
        if (x >= a[i]):
            ans[i] = 1
            x -= a[i]
        else:
            print(sum(ans))
            exit()
    if (0 in ans):
        print(sum(ans))
    else:
        print(sum(ans)-1)
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans, cur = 0, 0
if(sum(a) <= x):
    if(sum(a) != x): N -= 1
    print(N)
    exit(0)

for i in range(N):
    cur += a[i]
    if(cur > x): break
    ans += 1
print(ans)
N,X = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
count = 0
for i in A:
    if X >= i:
        X = X - i
        count += 1
    else:
        break
if X > 0 and count == N:
    count -= 1
print(max(count,0))
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
a.sort()
for num in a:
    if x >= num:
        ans += 1
        x -= num
    else:
        break
else:
    if x == 0:
        print(ans)
    else:
        print(ans - 1)
    exit()
print(ans)
N,x = map(int, input().split())
A = sorted(map(int, input().split()))

S = 0
c = 0

for i in range(N):
  S += A[i]
  
if S < x:
  print(N-1)
else:
  for i in range(N):
    b = x - A[i]
    if b > 0:
      c += 1
      x -= A[i]
    elif b == 0:
      c += 1  
      break
    else:
      break
  print(c)
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
res = 0
for a in A:
    x -= a
    res += 1
    if x < 0:
        x = abs(x)
        break
    elif x == 0:
        break

print(max(res-1, 0) if x>0 else res)
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:
        break
    ans += 1

if x>0:
    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)
        break

if x >0:
    print(n-1)
elif x==0:
    print(n)
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)
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(1, len(A)+1):
    #print(i)
    #print(A[:i])
    #print(sum(A[:i]))
    if x < sum(A[:i]):
        #print('a')
        print(i-1)
        break
    elif x == sum(A[:i]):
        #print('b')
        print(i)
        break
    else:
        if i == len(A):
            print(i-1)
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

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


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

ans = 0
total = 0

a_list.sort()

for i, a in enumerate(a_list):
    total += a

    if x < total:
        break
            
    elif i == len(a_list) - 1 and x > total:
        None
        
    else:
        ans += 1
    
print(ans)
N,x=map(int, input().split())
A=list(map(int, input().split()))

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

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

if x > 0:
    ans -= 1
else:
    pass

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

i = 0
while True:
    x = x - a[i]
    if x >= 0 and i+1 != len(a):
        i += 1
    elif x == 0 and i+1 == len(a):
        i += 1
        break
    else:
        break

print(i)
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(S, x)
    print(N - 1 if k == N else k)
n,x=list(map(int,input().split()))
a=sorted(list(map(int,input().split())))
i=0
num=0
for i in a:
    x=x-i
    num+=1
    if x==0:
        break
    if x<=0:
        num-=1
        break
if x>0:
    num-=1
print(num)
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

result = 0
a_sum = 0
for i in range(N):
    if i == N - 1:
        result += a[i] == x
    elif x >= a[i]:
        x -= a[i]
        result += 1
    else:
        break
print(result)
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 - 1
elif 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
while x>0 and a:
    c = a.pop(0)
    if x>=c:
        ans +=1
    x-=c
if x>0:
    ans-=1
print(ans)
def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for v in a:
        if v > x:
            x = 0
            break
        else:
            x -= v
            ans += 1
    if 0 < x:
        ans -= 1
    print(ans)

if __name__ == "__main__":
    main()
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
bit = 0
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        ans += 1
    else:
        bit = 1
if x != 0 and bit == 0:
    ans = max(0, ans - 1)
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:
    p = 0
    a.sort()
    for i in range(n):
        if a[i] > x:
            break
        else:
            x -= a[i]
            p += 1
    print(p)
N,x = map(int,input().split())

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

a.sort()
cnt=0

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

if x >0:
    if cnt == 0:
        cnt = 0
    else:
        if cnt == len(a):
            cnt = cnt -1
        
print(cnt)
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]:
        ans += 1
        x -= a[i]
    else:
        break

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

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

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

print(cnt if x <= 0 else cnt-1)
import math

#n, a, b= map(int, input().split())
n, x  = map(int, input().split())
a = list(map(int, input().split()))
#s = list(str(input()))
#n = int(input())

#a = [""]*n
#for i in range(n):
#  a[i] = str(input())

#for i in range(n):
a.sort()
tot = 0
for i in range(n):
  tot = tot + a[i]
  if(x < tot):
    print(i)
    break

if(x == tot):
  print(i+1)
if(x > tot):
  print(i)
n, x = list(map(int, input().split()))
a_list = sorted(sorted(map(int, input().split())))

# a_listの総和が全お菓子の数と同じなら答えはN, そうでないならN-1以下
if sum(a_list) == x:
    print(n)
    exit()

ans = 0

for i, a in enumerate(a_list):
    # 答えはN-1以下
    if i == len(a_list) - 1:
        break

    if x < a:
        break
    x -= a
    ans += 1

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

newLi = sorted(li)
ans = 0

for i in range(len(newLi)):
  if x - newLi[i] < 0:
    break
   
  if i == (len(newLi) - 1) and x != newLi[i]:
    break
  
  x -= newLi[i]
  ans += 1

print(ans)
n,x = map(int,input().split())
l = sorted(list(map(int,input().split())))
pe = 0
for i in l:
  if x-i>=0:
    x -= i
    pe += 1
  else:
    break
if x!=0 and n==pe:
  print(pe-1)
else:
  print(pe)
N,n=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

ans=0
i=0
while A[i]<=n:
  if i==N-1:
    if n==A[i]:
      ans+=1
    break
  else:
    ans+=1
    n-=A[i]
    i+=1  
print(ans)
n, x = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])
ans = 0
for i in range(n):
    x -= a[i]
    if x < 0:
        break
    else:
        ans += 1
print(ans - 1 if x > 0 else ans)
N,x = input().split()
A = input().split()
a = []
for i in range(int(N)):
  a.append(int(A[i]))
  
a.sort()
X = int(x)
 
idx = 0
while X>0 and idx<int(N):
  X = X-a[idx]
  idx+=1

if X==0:
  idx+=1
  
print(idx-1)
N, X = map(int, input().split())
lists = list(map(int, input().split()))

if X - sum(lists) == 0:
    print(len(lists))
    exit()

count = 0
for num in sorted(lists):
    X -= num
    if X >= 0:
        count += 1

if X < 0:
    print(count)
else:
    print(count - 1)
n, x = map(int, input().split())
num_lists = list(map(int, input().split()))

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

if 0 < x:
    cnt -= 1

print(cnt)
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
total=0
j=0
ssum=sum(a)

if ssum>=x:
    for i in range(N):
        total+=a[i]
        if total>x:
            break
        j+=1
    print(j)
else:
    print(N-1)
n,x=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
ans=ac=0
for i in l:
    ac+=i
    if x>=ac:
        ans+=1
if ac<x:
    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

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

print(cnt)
N, x = map(int, input().split())
list_a = [int(x) for x in input().split()]

list_a.sort()
total = sum(list_a)
if x < list_a[0] :
    print(0)
    exit()
if x > total :
    print(len(list_a)-1)
    exit()
ans = 0

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

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

A = sum(a)
if x > A:
    print(N-1)
elif x == A:
    print(N)
else:
    t = 0
    for n in range(N):
        t += a[n]
        if t > x:
            print(n)
            break
n,x = map(int,input().split())
a = [int(x.strip()) for x in input().split()]
a_sorted = sorted(a)
ch,ans = 0,0
for i in range(n):
  ch = sum(a_sorted[:i+1])
  if ch < x:
    ans += 1
  elif ch == x:
    ans += 1
    break
  else:
    break
if n == ans and sum(a) < x:
  ans -= 1
print(ans)
try:
  N, x = map(int, input().split())
  a = list(map(int, input().split()))
  a_ = sorted(a)
  cnt = 0
  for i in range(len(a_)-1):
      if a_[i]<=x:
          cnt += 1
          x = x-a_[i]
  if a_[len(a_)-1]-x==0:
      cnt += 1
  print(cnt)
except EOFError:
  pass
n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
for aa in a[:-1]:
  x -= aa
  if x >= 0:
    ans += 1
  else:
    break

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

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