peterverebics/CodeNet_Python_118 huggingface dataset:
# -*- coding:utf-8 -*-
N,x = map(int,input().split())
a = list(map(int,input().split()))

cnt = 0
a.sort()

while x > 0:
    if cnt >= N:
        if x > 0:
            cnt -= 1
            break
        else:
            break
    elif a[0] > x:
        break
    else:
        tmp = a.pop(0)
        x -= tmp
        cnt+=1


print(cnt)
if __name__ == "__main__":
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

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

    a.sort()

    ans = 0
    for i in range(n):
        if sum(a[:i+1]) <= x:
            ans = i+1
        else:
            print(i)
            exit()

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

if x == lst[N-1]:
    cnt +=1
    
print(cnt)
N, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0

a.sort()

for idx, v in enumerate(a):
    if v <= x:
        x -= v
        if idx == N - 1:
            if x == 0:
                count += 1
        else:
            count +=1

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

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

res=0
i=0
a.sort()

while 0<x and i < n:
    if a[i] <= x:
        res+=1
    x-=a[i]
    i+=1
if 0 < x:
    print(res-1)
else:
    print(res)
n, x = map(int, input().split())
lst = [0] + sorted(list(map(int, input().split())))
for i in range(n):
  lst[i + 1] += lst[i]
for i in range(n):
  if lst[i] <= x < lst[i + 1]:
    print(i)
    exit()
if x == lst[n]:
  print(n)
else:
  print(n - 1)
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 i==N and x>0:
  i-=1
print(i)
N,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(N):
    x -= a[i]
    if x < 0:
        break
    res += 1
if x > 0:
    res -= 1
print(res)
N,x = map(int,input().split())
a = map(int,input().split())
ret = 0
for i,n in enumerate(sorted(a)):
  if i == N-1 and n == x:
    x -= n
    ret += 1
  elif i < N-1 and n <= x:
    x -= n
    ret += 1
  else:
    break
print(ret)
def resolve():
    N,x = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    Acouont = 0
    ans = 0
    if sum(A) < x:
        print(N-1)
    else:
        for i in range(N):
            Acouont = Acouont + A[i]
            #print (Acouont)
            if Acouont > x:
                break
            ans += 1
        print(ans)   
resolve()
def resolve():
    n, x = map(int, input().split())
    a = [int(i) for i in input().split()]
    a = sorted(a)

    ans = 0
    for _a in a[:-1]:
        x = x - _a
        if x >= 0:
            ans += 1
    if x == a[-1]:
        ans += 1
    print(ans)


resolve()
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if sum(a)==x:
    print(N)
else:
    a.sort()
    s=0
    i=0
    while True:
       s+=a[i]
       if i==N-1 and s!=x:
           print(N-1)
           break
       if s>x:
           print(i)
           break
       i+=1
       if i>=N:
           print(N)
           break
from bisect import bisect_left
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[i]

idx = bisect_left(a_cs, x)
if idx == n + 1:
    ans = n - 1
elif a_cs[idx] > x:
    ans = idx - 1
else:
    ans = idx
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]:
        ans+=1
        x-=a[i]
    else:
        break
if ans==N:
    if x==0:
        pass
    else:
        ans-=1
print(ans)
#!/usr/bin/env python

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

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

cnt = 0 
al = False
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        cnt += 1
    else:
        break
    if i == n-1:
        al = True

if al: 
    if x > 0:
        ans = cnt-1
    else:
        ans = cnt 
else:
    ans = cnt 

print(ans)
[N, x] = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
count = 0
i = 0
while x > 0 and i <= len(a):
  x -= a[i]
  if i == len(a)-1:
    if x != 0:
      break
  if x >= 0:
    count += 1
  i += 1
  
print(count)
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0
for elem in a:
  if x >= elem:
    cnt += 1
    x -= elem
  else:
    break
print(cnt if cnt != N or x == 0 else cnt - 1)
n,x=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

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

a.sort()

cnt = 0
for i, child in enumerate(a):
    if x == 0:
        break
    if child == x:
        cnt += 1
        break
    if child < x:
        # 最後の要素か判定
        if i == len(a) - 1:
            break
        x -= child
        cnt += 1

print(cnt)
N, x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
f=0
i=0
while x>=a[i]:
    x=x-a[i]
    i=i+1
    f=f+1
    if i==N:
        break
if i==N and x>0:
    print(f-1)
else:
    print(f)
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, x = map(int, readline().split())
    a = list(map(int, readline().split()))
    a.sort()

    rem = x
    ans = 0

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

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

    print(ans)


if __name__ == '__main__':
    main()
#AGC027-A
n,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

cnt = 0
flg = True
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        cnt += 1
        
    else:
        flg = False
        break
        
if flg and x != 0:
    cnt -= 1
print(cnt)
import sys

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

c = 0
p = x

for i in range(n-1):
    if a[i] > p:
        print(c)
        sys.exit()
    else:
        c += 1
        p -= a[i]

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


if x == 0:
    print(count)
else:
    print(count-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]
if x > 0 and ans >= n:
  ans -= 1
print(ans)
def main():
    n, x = map(int, input().split())
    num_list = list(map(int, input().split()))

    ans = 0
    num_list.sort()

    for num in num_list:
        if x - num >= 0:
            x -= num
            ans += 1
        else:
            break

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

    print(ans)


if __name__ == '__main__':
    main()
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 X>0 and cnt==N:
    cnt-=1
print(cnt)
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 :
        x = 0
        break
if x != 0 :
    ans -= 1
print(max(0, ans))
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:
        ans += 1
        x -= a[i]
    else:
        break
else:
    if x != 0:
        ans -= 1


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

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

count = 0
for i, num in enumerate(nums):
    if (i < n-1 and num <= x) or (i == n-1 and num == x):
        count += 1
        x -= num        
    else:
        break

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

s = 0
num = 0
if x>sum(a):
  print(len(a)-1)
else:
  for i in range(len(a)):
      if x >= a[i]:
          x -= a[i]
          num += 1
      else:
          break

  print(num)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
for i, v in enumerate(a):
    x -= v
    if i == n - 1:
        if x == 0:
            ans += 1
        break
    else:
        if x >= 0:
            ans += 1
            continue
        else:
            break

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

a.sort()

res = 0

for aa in a:
    x -= aa
    if x < 0:
        print(res)
        exit()
    res += 1

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,h in enumerate(a[:-1]):
    x-=h
    if x>=0:ans+=1
if x==a[-1]:ans+=1
print(ans)
# A - Candy Distribution Again
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for a in A:
    x -= a
    if x<0 or (ans==N-1 and x!=0):
        break
    ans += 1
print(ans)
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-=a[i]
        count+=1
    else:
        print(count)
        exit()

if x>0:
    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(N):
  if x > A[i]:
    if i+1 == N:
      print(N-1)
      exit()
    else:
      ans += 1
      x -= A[i]
  elif x == A[i]:
    ans += 1
    print(ans)
    exit()
  else:
    print(ans)
    exit()
N,x = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
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()

rem = x
give = 0

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

if rem != 0:
    give -= 1

print(give)
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
    if i == n-1:
        if x > 0:
            break
    ans += 1

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

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

if x > 0:
    c -= 1

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

a.sort()

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

elif sum(a) > x:
    ans = 0
    ans_ = 0
    for a in a:
        ans_ += a
        if ans_ > x:
            break
        ans += 1
    print(ans)

elif sum(a) == x:
    print(N)
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:
    n=i
    break
if x <=0:
  print(n)
elif x > 0:
  print(n-1)
n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
if x > sum(A):
    print(n-1)
else:
    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.sort()
ans = 0
for a in A:
    x -= a
    if x < 0:
        break
    else:
        ans += 1
if 0 < x:
    ans -= 1

print(max(ans, 0))
n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
a.sort()
for i in a:
    if a.index(i) == n - 1:
        if i == x:
            cnt += 1
    elif i <= x:
        x -= i
        cnt += 1
    else:
        break
print(cnt)
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
tmp=x
ans=0
for i in a[:-1]:
    tmp=tmp-i
    if tmp>=0:
        ans+=1
if tmp==a[-1]:
    ans+=1
print(ans)
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect
from itertools import accumulate

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

b=list(accumulate(a))

if b[-1]<x:
  print(n-1)
else:
  inx=bisect(b,x)
  print(inx)
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
c = 0
ans = 0

for i in range(N):
    if c + a[i] <= x:
        c += a[i]
        ans += 1
    else:
        print(ans)
        exit()

if c == x:
    print(N)
else:
    print(N-1)
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt=0

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

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

a = sorted(a)

M = []
cn = 0

for i in range(N):
    x = x - a[i]


    
    if x >= 0 and i != N-1: 
        cn = cn + 1
    elif x < 0:
        print(cn)
        break
    elif i == N-1:
        if x == 0:
            cn = cn + 1
            print(cn)
            break
        else:
            print(cn)
            break
from sys import stdin
import math

[N, x] = list(map(int, stdin.readline().rstrip().split()))
a = list(map(int, stdin.readline().rstrip().split()))

a_sorted = sorted(a)


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

if x > 0:
    count -= 1

print(count)
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()
if cou == x:
    print(n)
else:
    print(n-1)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
total = sum(a)
ans = 0
if x == total:
    ans = n
elif x > total:
    ans = n - 1
else:
    for v in a:
        x -= v
        if x < 0:
            break
        ans += 1
print(ans)
N,x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

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

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

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

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

ans = 0
for i in range(N):
    if sum(A[:i]) <= x:
        ans = i
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if x == sum(a):
    print(n)
elif x > sum(a):
    print(n-1)
else:
    for i in range(n):
        if x < a[i]:
            print(i)
            break
        x -= a[i]
n, x = map(int, input().split())
ls = list(map(int, input().split()))
s = sum(ls)
if s < x:
    print(n - 1)
elif s == x:
    print(n)
else:
    ls.sort()
    a = 0
    for i in range(n):
        if ls[i] <= x:
            x -= ls[i]
            a += 1
        else:
            print(a)
            break
N, x = map(int,input().split())
a = sorted([int(i) for i in input().split()])
count = 0
if sum(a) == x:
    print(len(a))
else:
    for i in a:
        x = x-i
        if x<0:
            break
        count+=1
    if count == N:
        print(N-1)
    else:
        print(count)
def LI():
    return list(map(int, input().split()))


N, total = LI()
a = LI()
Nlist = [0]*N
a.sort()
ans = 0
if sum(a) == total:
    ans = N
elif sum(a) < total:
    ans = N-1
else:
    for i in range(N):
        if total == a[i]:
            ans += 1
            break
        elif total > a[i]:
            ans += 1
            total -= a[i]
        else:
            break
print(ans)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

l = sorted(a)
flag = False
for i in range(n):
    x -= l[i]
    if x < 0:
        flag = True
        break
if flag:
    print(i)
elif x == 0:
    print(n)
elif x > 0:
    print(n - 1)
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
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)
import sys
input = sys.stdin.readline

def main():
    N, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    ans = 0
    for a in sorted(a_list):
        if a <= x:
            ans += 1
            x -= a
        else:
            break
    if x == 0 or ans != N:
        print(ans)
    else:
        print(max(ans - 1, 0))

if __name__ == '__main__':
    main()
N,X=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
count=0
for i in range(N):
	if i==(N-1):
		if X!=L[i]:
			count=count
		else:
			count+=1
	elif L[i]<=X:
		X-=L[i]
		count+=1
	
print(count)
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N,x = inputlist()
a = inputlist()
a.sort()
count=0
for i in range(N):
    x -=a[i]
    if x < 0:
        print(count)
        exit()
    count +=1
if x >0:
    count -=1
print(count)
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()

if x>sum(a):
  print(n-1)
else:
  print(n)
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if sum(a) == x:
    print(N)
else:
    i = 0
    candy = 0
    while candy <= x and i <= N - 1:
        candy += a[i]
        i += 1
    print(i - 1)
N,X=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=0
for i in range(0,N):
    if X>=a[i]:
        X=X-a[i]
        b+=1
        if i==len(a)-1 and (X+a[i])!=a[i]:
            b-=1
            break
    else:
        break
print(b)
N,X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
k1 = k2 = 0
for i in range (N):
  if sum(A[:i+1]) > X:
    k1 = i
    k2 = 1
    break
  elif sum(A) == X:
    k1 = N
    k2 = 1
    break
if k2 == 0:
  k1 = N - 1
print(k1)
import sys
n,x = map(int, sys.stdin.readline().rstrip("\n").split())
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
a.sort()
ans = 0
for i in range(n):
    if i == n-1:
        if x - a[i] == 0:
            ans += 1
    else:
        if x-a[i] >= 0:
            x = x-a[i]
            ans += 1
print(ans)
n,x=[int(i) for i in input().split()]

a_list=[int(i) for i in input().split()]

a_list.sort()

if x>sum(a_list):
    print(n-1)

#全員喜ぶ    
elif x==sum(a_list):
    print(n)
    
else:
    sum=0
    count=0
    for i in range(n):
        sum+=a_list[i]
        if sum<=x:
            count+=1
        else:
            break
    print(count)
from itertools import accumulate
N, X = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
p = list(accumulate(a))

result = 0
for i, x in enumerate(p):
  if X < x:
    break
  if i == N-1 and x != X:
    break
  result += 1

print(result)
n,x,*a=map(int, open(0).read().split())
a.sort()
for i in range(n):
    x-=a[i]
    if x<0:
      print(i)
      exit()
    elif x==0:
      print(-~i)
      exit()
print(n-1)
def main():
    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)
    
if __name__ == "__main__":
    main()
n,x = map(int,input().split())

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

a.sort()

sweets=0

ans = 0

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

if sweets < x:
    print(ans-1)
else:
    print(ans)
n,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()

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

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

a.sort()

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

print(count)
N, x = map(int, input().split())
an = list(map(int, input().split()))
an.sort()
ans = 0
for a in an:
    x -= a
    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()))
temp=x
ans=0
a.sort()
i=-1
while True:
    i+=1
    x-=a[i]
    if x<0:
        break
    ans+=1
    if ans==N:
        break
if sum(a)<temp:
    ans-=1
    
print(ans)
N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
total=sum(a)
#おかしが余る場合
if total<x:
  print(N-1)
#配りきれる場合
elif total==x:
  print(N)
#子供が余る場合
else:
  ans=0
  d=[0]*N
  for i in range(N):
    if x>=a[i]:
      x-=a[i]
      d[i]=1
  ans=d.count(1)
  print(ans)
n,x=map(int,input().split())
a=sorted([int(i)for i in input().split()])
res=0
if sum(a)==x:
    res=n
else:
    for i in range(n):
        if sum(a[:i])<=x:res=i
print(res)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(n-1):
  if a[i] <= x:
    x = x - a[i]
    count += 1
if a[n-1] == x:
  count += 1
    
print(count)
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
i = 0
while i<N and x>=A[i]:
    x -= A[i]
    i += 1
if x>0 and i==N:
    i -= 1
print(i)
N, x = map(int, input().split())
A = sorted(map(int, input().split()))

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

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

    if c == N:
        print(N - 1)
    else:
        print(c + 1 if x == 0 else c)