peterverebics/CodeNet_Python_118 huggingface dataset:
n,x = map(int,input().split())
A = sorted(map(int,input().split()))
ans = 0
if x < A[0]:
  print(0)
  exit()
for i in range(n):
  x -= A[i]
  ans += 1
  if x < 0:
    ans -= 1
    break
print(ans)
N,x = list(map(int,input().split()))
A = list(map(int,input().split()))
count = 0
for a in A:
    if x >= a:
        x -= a
        count += 1
if x > 0:
    print(max(count-1,0))
else:
    print(count)
n, x = map(int, input().split())
A = list(map(int, input().split()))


if sum(A) < x:
    x -= sum(A)
    A.sort()
    ans = n
    
    for a in A:
        if x - a >= 0:
            x -= a
            ans -= 1
        # else:
        #     break

else:
    A.sort(reverse=True)
    ans = 0
    for a in A:
        if x - a >= 0:
            x -= a
            ans += 1
        # else:
        #     break


print(ans)
N, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
  if X >= A[i]:
    X -= A[i]
    ans += 1
print(ans)
import sys

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

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

a.sort()

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

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

print("{}".format(cnt_children))
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

print(ans)
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)
n,x= map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
s = 0
for i in range(n):
    s += a[i]
    if s > x:
        i -= 1
        break
print(i+1)
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if x < min(A):
    print(cnt)
    break
  elif i == N-1:
    print(N)
  else:
    x -= min(A)
    A.remove(min(A))
    cnt += 1
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>0 and x>0:
    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]:
  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.sort()
cnt=0
for i in range(N):
    if A[i]<=X:
        X-=A[i]
        cnt+=1
if X>0 and cnt>0:
    cnt-=1
print(cnt)
N, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
a.sort()
for i in range(N):
    if a[i]<=x:
        x -= a[i]
        cnt += 1
    else:
        break
if (x!=0)and(cnt!=0):
    cnt -= 1
print(cnt)
# A - Candy Distribution Again
count = 0
N, x = map(int, input().split())
A = input().split()
A.sort()
for i in range(N):
    if(x == 0):
        break
    if(i == N-1):
        #最後なので全部あげる
        if(x == int(A[i])):
            count += 1
    else:
        x -= int(A[i])
        if(x >= 0):
            count += 1
print(count)
p_c,k_c=(int(x) for x in input().split())
al=list(map(int,input().split()))
al.sort(reverse=True)
count=0
for i in range(p_c):  
  if i==al.index(al[-1]):
    k_c=k_c-al[i]
    if k_c==0:
      count+=1
    else:
      break
  else:
    k_c=k_c-al[i]
    count+=1
print(count)
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
flag=False
for i in a:
  temp=x-i
  if temp>=0:
    flag=True
    x-=i
    ans+=1
if flag==False:
  print(0)
  exit()
print(ans if x==0 else ans-1)
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
print(ans)
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:
        break
        
print(ans)
n, x = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
ans = 0
for consume_v in arr:
    if x >= consume_v:
        x -= consume_v
        ans += 1
    else:
        break
if x > 0:
    if ans != 0:
        ans -= 1
print(ans)
N,x=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)==x:
  print(N)
  exit()
else:
  a.sort()
  ans=0
  flag=False
  for i in a:
    temp=x-i
    if temp>=0:
      flag=True
      x-=i
      ans+=1
  if flag==False:
    print(0)
    exit()
  print(ans if x==0 else ans-1)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

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

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

# 全員に配り終えても余っている場合は、残りのクッキーを1人にわたす
if count == N and x > 0:
    count =- 1

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

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

a.sort()

s=0
i=0

if sum(a)<x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i)
n, x = map(int, input().split())
li_a = list(map(int, input().split()))

answer = 0

for a in sorted(li_a):
    if x >= a:
        answer += 1
        x -= a
    else:
        break
print(answer if (x == 0 or answer == 0) else answer - 1)
n,x,*a=map(int, open(0).read().split())
a.sort()
i=0
while 0<x and i<n:
    x-=a[i]
    i+=1
print(~-i)
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
    tmp = 0
    for aa in a:
        if tmp < x and aa <= x-tmp:
            tmp += aa
            ans += 1
        if tmp == x:
            print(ans)
            exit()
    if x-tmp > 0:
        ans -= 1

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

arr.sort()
ans = 0
for consume_v in arr:
    if x > consume_v:
        x -= consume_v
        ans += 1
    elif x == consume_v:
        x -= consume_v
        ans += 1
    else:
        break
if x > 0:
    if ans != 0:
        ans -= 1
print(ans)
n, x = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()
ans = 0

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

print(ans)
try:
  N, x = map(int, input().split())
  a = map(int, input().split())
  a_ = sorted(a)
  cnt = 0
  for i in a_:
      if i<=x:
          cnt += 1
          x = x-i
      else:
          break
  print(cnt)
except EOFError:
  pass
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 :
    print(ans)
    break
  else:
    x -= A[i]
    ans += 1
    if i == N-1:
      print(N-1)
      break
n,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
for i in a:
    if x >= i:
       cnt += 1
       x -= i
if x > 0:
    cnt -= 1
if cnt < 0:
    cnt = 0
print(cnt)
n, x, *a = map(int, open(0).read().split())
a.sort()
cnt = 0
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        cnt += 1
        print(a,x,cnt)
    else:
        break
if x > 0:
    cnt -= 1
print(max(cnt,0))
def solve(n, x, A):
    A.sort()
    count = 0
    for a in A:
        if a <= x:
            x -= a
            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())
# a=[int(input()) for i in range(4)]
a = list(map(int,input().split()))
count = 0
#昇順に並べ替える
sort_a = sorted(a)

for i in range(N):
    print(i)
    if x >= sort_a[i]:
        count += 1
        x -= sort_a[i]
        # print(x)
        continue
    break
print(count)
N,x = map(int,input().split())
a = list(map(int,input().split()))

A = sorted(a)

n = 0

for i in A:
  x -= i
  n += 1
  if x==0:
    print(n)
    break
  elif x<0:
    print(n-1)
    break
  elif i == A[N-1]:
    print(n-1)
    break
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))

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

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

ans = 0
for i in l:
    if i <= x:
        x -= i
        ans += 1
print(ans)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0

for i in a:
    if x >= i:
        x -= i
        count += 1
    else:
        pass

if x > 0:
    count -= 1

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

a.sort()

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

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

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

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

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

# 小さい数から配っていくと子供の人数を最大化できる
a = sorted(a)

leftCandy = 0
childrenCnt = 0
for i in range(len(a)):
  leftCandy = x - a[i]
  if leftCandy >= 0:
    childrenCnt += 1

if leftCandy > 0:
  childrenCnt -= 1

print(childrenCnt)
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 > 0 else 0
print(count)
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(len(a)):
    if x - a[i] >= 0:
        x -= a[i]
        count += 1
    else:
        break
print(count)
N, x = map(int, input().split())
array = list(map(int, input().split()))
array = sorted(array, reverse=False)
#print(array)
for i in range (N):
  if sum(array) < x:
    print(N)
    break
  elif sum(array[0:i+1]) == x:
    print(i)
    break
  elif sum(array[0:i+1]) < x and x < sum(array[0:i]):
    print(i-1)
    break
  else:
    pass
N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
i = 0
for i in range(N):
    if M - int(L[0]) > 0:
        M -= int(L[0])
        total += 1
        L.pop(0)
        i += 1
        
print(total)
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:
    print(z+1)
    break
else:
  print(N)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
i = 0
while True:
    an = a.pop()
    x -= an
    ans += 1
    i += 1
    if len(a) == 0 or i == n:
        break
if x == 0:
    ans += 1
print(ans - 1)
N,x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
count = 0

for i in range(N):
  b = x - A[i]
  if b > 0:
    count += 1
    x -= A[i]
  else:
    exit()
print(count)
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
s = x
cnt = 0
if sum(a) > s:
    print(N-1)
elif s >= a[0]:
    for i in range(N):
        if s >= a[i]:
            cnt += 1
            s -= a[i]
    print(cnt)
N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
print(i-1)
from itertools import accumulate

N, x, *A = map(int, open(0).read().split())
A.sort()
B = list(accumulate(A)) # cumsum

def f(B, x):
    ans = 0
    for b in B:
        ans += 1
        if x == b:
            break
        elif x < b:
            ans -= 1
            break
    return ans

if B[-1] < x:
    x -= B[-1]
    ans = len(A) - f(B, x)
else:
    ans = f(B, x)

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

a.sort()

ans = 0
i = 0

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

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

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

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]:
        b=b-c[i]
        total+=1
    else:
        print(total)
        break
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

A.sort()
ans = []
for i in A:
	ans.append(i)
	x -= i
	#print(ans, x)
	if x <= 0:
		break

print(len(ans))
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
if 0 < x:
    ans -= 1

print(max(ans, 0))
N, x = map(int,input().split())
al = list(map(int,input().split()))

al.sort()

cnt = 0
for a in al:
  x -= a
  cnt += 1
  if x < 0:
    break
print(cnt)
n, x=map(int, input().split())
c=list(map(int, input().split()))
c.sort()
ans=0
for g in c:
  if g<=x:
    x-=g
    ans+=1
  else:
    break
if x>0:
  print(0)
else:
  print(ans)
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 x>0:
    print(f-1)
else:
    print(f)
# 27 --- > dbt
# try 1

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

for i in range(len(a)-1):
    if x >= a[i] :
        num += 1
        x -= a[i]
    else:
        left += a[i]

if num == (n-1) and x == a[-1]:
    num += 1
elif num != (n-1) and x >= a[-1]:
    num += 1
    
print(num)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)

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 = sorted(map(int,input().split()))
ans = 0
for i in range(n):
  x -= A[i]
  ans += 1
  if x < 0:
    ans -= 1
    break
print(ans)
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
print(count)
n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
tank = 0
for i in range(n):
    if tank+A[i] <= x:
        tank += A[i]
        cnt += 1
    else:
        break
print(cnt if tank==x else max(cnt-1, 0))
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
c,i=0,0
while(i<n and x>0):
  if a[i]<=x:
    x-=a[i]
    c+=1
    i+=1
  else:
    break
print(c)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
i = 0

while i < n:
    x -= a[i]
    if (x < 0):
        break
    i += 1

print(i)
from itertools import accumulate


def LI():
    return list(map(int, input().split()))


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

A = sorted(a)

n = 0

for i in A:
  x -= i
  n += 1
  if x==0:
    print(n)
    break
  elif x<0:
    print(n-1)
    break
  elif i == A[N-1]:
    print(n-1)
from itertools import accumulate

n, x, *aa = map(int, open(0).read().split())

aa.sort()

aa = list(accumulate(aa))

print(max(len([a for a in aa if a<=x])-1+(x in aa), 0))
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = 0
for ai in a:
    if x - ai < 0:
        break
    x -= ai
    ans += 1
if x > 0 and ans > 0:
    ans -= 1
print(ans)
# 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]
    if x>=a:
        person_num += 1
        x = x - a
    else:
        break

# output
print(person_num)
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=0
if a[0]>x:
    print(0)
    exit()
if sum(a)<x:
    print(n-1)
    exit()
for i in range(n):
    if s+a[i]<x:
        s+=a[i]
    else:
        print(i+1)
        exit()
#22
N,x = map(int,input().split())
a = list(map(int,input().split()))
cou =0

a.sort()

for i in a:
    if i >x:
        break
    cou +=1
    x -= i
    
if x>0:
    for i in a:
        if x%i ==0:
            cou -=1
            break
        while x > i:
            x-=i
            
print(cou)
n, x = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
ans = 0
for i in range(n):
  if a[i] <= x:
    ans += 1
    x -= a[i]
  else:
    break
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:
    res -= 1
print(res)
# agc027_a.py
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0
for i in a:
    if x>=i:
        cnt += 1
        x -= i
print(cnt)
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0

try:
    while x >= a[0]:
        x -= a.pop(0)
        count += 1
except IndexError:
    pass

print(count)
N, X = map(int, input().split())
la = sorted(list(map(int, input().split())))

if X < la[0]:
    print(0)
elif X > sum(la):
    print(N-1)
elif X == sum(la):
    print(N)
else:
    j = 0
    while X > 0:
        X = X - la[j]
        j += 1
    print(j)
n,x=map(int,input().split())
l=sorted(list(map(int,input().split())))

num=0
c=0

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

if x == 0:
  print(ans)
else:
  print(max(0,ans-1))
a,b=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
if sum(L)<b:
  print(a-1)
elif sum(L)==b:
  print(a)
else:
  for i in range(a):
    ans+=L[i]
    if ans>=b:
      print(i+1)
      exit()
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
c,i=0,0
while(i<n and x>0):
  if a[i]<=x:
    x-=a[i]
    c+=1
    i+=1
  else:
    break
  if i==n-1 and x!=0:
    c-=1
print(c)
N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
sum = 0
index = 0
for i in range(N):
    sum += num_list_s[i]
    if sum > X:
        break
    else:
        index += 1
print(index)
n, x= map(int, input().split())
a = list(map(int, input().split()))
a.sort()
wa = 0
cnt = 0
for i in a:
    wa += i
    cnt += 1
    if wa > x:
        print(cnt - 1)
        exit()
        
    elif wa == x:
        print(n)
        exit()
print(n)
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, X = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    A.sort()
    ans = 0
    for a in A:
        if X >= a:
            ans += 1
            X -= a
    if X != 0 and ans != 0:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=a[0]
y=a[1]
b.sort()
i=0
k=0
while i ==0:
	t=b[0]
	if y>=t:
		k=k+1
		del b[0]
	else:
		i=1
	if x==k:
		i=1
print(k)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
if sum(a) < x:
    print(n-1)
    exit()
if sum(a) == x:
    print(n)
    exit()
idx = s = 0
while True:
    s += a[idx]
    if x == s:
        print(idx+1)
        exit()
    if x < s:
        print(max(0, idx-2))
        exit()
# A - Candy Distribution Again
count = 0
N, x = map(int, input().split())
A = input().split()
A.sort()
A_i = [int(s) for s in A]
for i in range(N-1):
    x -= A_i[i]
    if(x < 0):
        break
    count += 1
if(x == A_i[N-1]):
    count += 1
        
print(count)
N, x = map(int,input().split())
a = sorted(list(map(int,input().split())))

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

if x>0 and i==N-1:
    ans-=1
print(ans)
N, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0

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

print(count)
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_left(c, x)
if not ans:
  print(ans)
else:
  print(ans if ans != N else ans - 1)
N, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
a.sort()
for i in range(N):
    if a[i]<=x:
        x -= a[i]
        cnt += 1
    else:
        break
if x!=0:
    cnt -= 1
print(cnt)
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:
        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(reverse=True,key=int)
ans=0
for i in range(n-1):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ans+=1
print(ans)
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 x > sum(A):
  ans -= 1
print(ans)
n, k =map(int,input().split())
data = list(map(int,input().split()))
cnt = 0
for var in data:
    if var <= k:
        cnt += 1
        k = k-var
       
    else:
        continue
print(cnt)