Problem:
 Score : 200 points    Problem Statement There are N children, numbered 1, 2, ..., N .  Snuke has decided to distribute x sweets among them.
He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i ( 1 \leq i \leq N ), Child i will be happy if he/she gets exactly a_i sweets.
Snuke is trying to maximize the number of happy children by optimally distributing the sweets.
Find the maximum possible number of happy children.      Constraints  All values in input are integers.  2 \leq N \leq 100  1 \leq x \leq 10^9  1 \leq a_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  x  a_1  a_2  ...  a_N       Output Print the maximum possible number of happy children.        Sample Input 1 3 70
20 30 10      Sample Output 1 2  One optimal way to distribute sweets is (20, 30, 20) .       Sample Input 2 3 10
20 30 10      Sample Output 2 1  The optimal way to distribute sweets is (0, 0, 10) .       Sample Input 3 4 1111
1 10 100 1000      Sample Output 3 4  The optimal way to distribute sweets is (1, 10, 100, 1000) .       Sample Input 4 2 10
20 20      Sample Output 4 0  No children will be happy, no matter how the sweets are distributed.

Solution (Python):
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
s = 0
i = 0
for a in a_list:
    s += a
    if s > x:
        print(i)
        break
    else:
        i += 1
else:
    if s == x:
        print(N)
    else:
        print(N-1)

Solution (Python):
N,x = map(int,raw_input().split())
a = map(int,raw_input().split())

a.sort()

score = 0
count = N
for i in range(N):
    score+=a[i]
    if score > x:
        count = i
        break

if count==N and score<x:
    count-=1

print count

Solution (Python):
N,x = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort()

counter = 0
for i in range(len(a)):
    x = x - a[i]
    if x < 0:
        break
    counter = counter + 1

if x > 0:
    counter = counter - 1

print(counter)

Solution (Python):
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
already = []
ans = 0
while len(a) != 1:
    comp = a.pop(0)
    if  comp <= x:
        ans += 1
        x -= comp
    else:
        print(ans)
        exit()

if a[0] == x:
    print(ans+1)
else:
    print(ans)

Solution (Python):
def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    ss = sum(a)
    if ss < x:
        print(n-1)
    elif ss == x:
        print(n)
    else:
        a.append(10 ** 12)
        a.sort()
        candy = 0
        for i in range(n+1):
            candy += a[i]
            if candy > x:
                print(i)
                break


if __name__ == '__main__':
    main()

Solution (Python):
import bisect
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = sum(a)
if x > s:
    print(N - 1)
elif s == x:
    print(N)
else:
    a_cum = [0] * (N + 1)
    for i in range(N):
        a_cum[i + 1] = a_cum[i] + a[i]
    ans = bisect.bisect_right(a_cum, x)
    print(ans - 1)

Solution (Python):
n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))

def main():
	capacity = sum(a)
	if x > capacity:
		print(n - 1)
		return
	elif x == capacity:
		print(n)
		return
	else:
		b = sorted(a)
		ans = 0
		y = x
		for i in range(0, n):
			y -= b[i]
			if y < 0:
				break
			ans += 1
		print(ans)
		return

main()

Solution (Python):
N, x = map(int, input().split())
A = list(map(int, input().split()))


A.sort()


ans = 0
i = 0
while(i < len(A) - 1):
    a = A[i]
    
    x -= a
    if(x >= 0):
        ans += 1
    else:
        break

    i += 1

if(i == len(A) - 1 and x == A[N - 1]):
    ans += 1

print(ans)

Solution (Python):
n,x = map(int,input().split())
arr = list(map(int,input().split()))
ans = 0;
arr.sort();
flag = 0;

for i in range(n):

	if x < arr[i]:
		flag=1;
		break;
	else:
		ans+=1;
		x -= arr[i];

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

print(ans);

Solution (Python):
N,x=map(int, raw_input().split() )
A=map(int, raw_input().split() )

A.sort()

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

print ans

Solution (Python):
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0
i = 0
while x > 0:

    
    if a[i] <= x:
        
        if a[i] != x and i == N - 1:
            break
        else:
            x -= a[i]
            ans += 1
    
    else:
        break

    
    if i < N-1:
        i += 1
    else:
        break

print(ans)

Solution (Python):
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i,j in enumerate(a):
    if x - j < 0:
        print(i)
        break
    else:
        x = x - j
else:
    if x == 0:
        print(i + 1)
    else:
        print(i)

Solution (Python):
n, x = map(int, input().split())

lis = map(int, input().split())


count = 0
for i in sorted(lis):
    x -= i
    if x < 0:
        break
    count += 1

if x > 0:
    count -= 1

print(count)

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

if sum(a) == x:
    print(n)
elif sum(a) > x:
    num = 0
    for i,ax in enumerate(a):
        num += ax
        if num > x:
            print(i)
            exit()
else:
    print(n-1)

Solution (Python):
N, x = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
S = 0
c = 0
if sum(A) < x:
    print(N-1)
else:
    for i in A:
        if S + i <= x:
            S += i
            c += 1
        else:
            break
    print(c)

Solution (Python):
n,x = map(int,input().split(" "))

array = list(map(int,input().split(" ")))
array = sorted(array)
ans = 0
for i in range(n-1):
    x = x - array[i]
    if x < 0:
        break
    ans += 1
if x == array[-1]:
    ans += 1
print(ans)

Solution (Python):
N, x = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
res = 0
count = x
for i in range(N):
    count -= l[i]
    res += 1
    if count == 0:
        break
    if count < 0:
        res -= 1
        break

if sum(l) - x < 0:
    res -= 1

        
print(res)

Solution (Python):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
r=0
s=0
for i in a:
    s+=i;r+=1
    if s>=x:break
if s==x:print(r)
else:print(r-1)

Solution (Python):
N,x = map(int, raw_input().split())
a = map(int, raw_input().split())

S = sum(a)
if x>S:
  print N-1
elif x==S:
  print N
else:
  a.sort()
  ans = 0
  for t in a:
    if x>=t:
      x -= t
      ans += 1
  print ans

Solution (Python):
n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
ans = s = 0
for i, t in enumerate(a):
    if s > x:
        break
    for j in xrange(i, n):
        if s + a[j] == x:
            ans = i + 1
        if ans < i:
            ans = i
    s += t
print ans

Solution (Python):
N,x = map(int,input().split())
A = list(map(int,input().split()))
answer = 0
while x > 0  :
    A = sorted(A)
    if x < A[0] :
        break
    x = x - A[0]
    answer += 1
    A.pop(0)
    if len(A) == 0 :
        if x != 0 :
            answer -= 1
        break
print(answer)

Solution (Python):
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
for i in range(N):
    res = i
    if x > A[i]:
        x -= A[i]
    elif x == A[i]:
        res += 1
        break
    else:
        break
print(res)

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if a[0] > x:
  print(0)
  exit()

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


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

print(count)

Solution (Python):
import math


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

    bi = []
    t = 0
    for a in ai:
        t += a
        bi.append(t)

    def solve():
        cc = 0
        for i in range(N):
            if bi[i] < x:
                cc += 1
                continue
            if bi[i] == x:
                return cc + 1
            if bi[i] > x:
                return cc
        return cc - 1

    cc = solve()
    print(cc)


if __name__ == '__main__':
    main()

Solution (Python):


import math
import sys
import itertools
import numpy as np


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


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

a=sorted(a)


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

    else:
        break
if x == a[n-1]:
    answer += 1
print(answer)

Solution (Python):
def bubble(a):
    for i in range(len(a)-1):
        for j in range(len(a)-1-i):
            if a[j] > a[j+1]:
                tmp=a[j]
                a[j]=a[j+1]
                a[j+1]=tmp

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

a = list(map(int,input().split()))
bubble(a)
ans = 0

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

Solution (Python):


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

al = [int(x) for x in input().split()]


al.sort()

count=0
acc = 0
for ai in al:
    acc += ai
    if acc > x:
        break
    count+=1
if acc < x:
    count -= 1

print(count)

Solution (Python):
N,x = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
i = 0
tmp = 0
while True:
    if i == len(A):
        if  x - tmp == 0:
            print(i)
            exit()
        else:
            print(i - 1)
            exit()
    else:
        tmp += A[i]
        if tmp > x:
            print(i)
            exit()
        else:
            i += 1

Solution (Python):
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

count = 0

for i in range(N):
    if a[i] <= x and i != (N-1):
        count += 1
        x -= a[i]
    elif a[i] == x and i == (N-1):
        count += 1

print(count)

Solution (Python):
from sys import stdin

N, x = [int(a) for a in stdin.readline().rstrip().split()]
a = [int(b) for b in stdin.readline().rstrip().split()]
a.sort()

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

print(ans)

Solution (Python):
N, x = list(map(int, input().split()))

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

c_list.sort()


i = 0
for _ in range(len(c_list)):
    if x - c_list[i] < 0:
        print(i)
        exit()
    x -= c_list[i]
    i += 1

if x == 0:
    print(len(c_list))
else:
    print(len(c_list) - 1)

Solution (Python):
N, x = map(int, input().split())
As = list(map(int, input().split()))

As.sort()

ans = 0
for A in As:
    if x > A:
        x -= A
        ans += 1
    elif x == A:
        ans += 1
        break
    else:
        break
else:
    ans -= 1

print(ans)

Solution (Python):
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))

ans = 0
for a in A:
    if x >= a:
        x -= a
        ans += 1

if ans == N:
    print(ans - (x != 0))
else:
    print(ans)

Solution (Python):
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
cnt = 0
for i in range(n):
    if x - a[i] < 0:
        break
    elif x - a[i] == 0:
        x -= a[i]
        cnt += 1
    else:
        if i+1 == n:
            break
        else:
            x -= a[i]
            cnt += 1
print(cnt)

Solution (Python):
N,x=map(int,input().split(" "))
A=list(map(int,input().split(" ")))

A=sorted(A)

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

print(ans)

Solution (Python):
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
k = 0; ans = 0
while A[k] <= x:
    ans += 1
    x -= A[k]
    if k+1 == N:
        A[k] = x+1
        if x > 0:
            ans -= 1
    else:
        k += 1
print(ans)

Solution (Python):
DT = input()
data = DT.split()

N = int(data[0])
x = int(data[1])

DT = input()
a = DT.split()
for lop in range(len(a)):
    a[lop] = int(a[lop])
a = sorted(a)

cnt = 0
for lop in range(len(a)):
    if x < 0:
        break
    x -= a[lop]
    cnt += 1

if not(x == 0):
    cnt -= 1

print(cnt)

Solution (Python):
import numpy as np

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

cum = np.cumsum(a)

if x == cum[-1]:
    print(n)
elif x > cum[-1]:
    print(n-1)
else:
    temp = cum <= x
    print(sum(temp))

Solution (Python):
N, K = [int(i) for i in input().split(' ')]
As = [int(i) for i in input().split(' ')]

r = 0
f = 1
for i in sorted(As):
    K -= i
    if K < 0:
        f = 0
        break
    r += 1

if f == 1 and K != 0:
    print(r-1)
else:
    print(r)

Solution (Python):
n, x = map(int, raw_input().split())
a = map(int, raw_input().split())

if sum(a) < x:
    print(n-1)
else:
    t = 0
    s = 0
    for i in sorted(a):
        s += i
        if s <= x:
            t += 1
            continue
        else:
            break
    print(t)

Solution (Python):
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
ans = 0

for ai in a[:-1]:
    if x >= ai:
        x -= ai
        if x >= 0:
            ans += 1
    else:
        break

if x == a[-1]:
    ans += 1
    
print(ans)

Solution (Python):
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:
        break
    x -= a[i]
    ans += 1

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

print(ans)

Solution (Python):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]

def main():
    n, x = na()
    aa = na()

    aa.sort()
    

    c = 0
    for a in aa:
        x -= a
        if x >= 0:
            c += 1
            
    if x > 0:
        c -= 1
    print(c)


main()

Solution (Python):


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

if __name__ == '__main__':
    main()

Solution (Python):
n, c = [int(x) for x in input().split()]
cs = sorted(int(x) for x in input().split())

cum = 0
res = 0
for i, ch in enumerate(cs):
  cum += ch
  if cum > c: break
  res += 1

print(res if cum >= c else res - 1)

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

Solution (Python):
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
count=0
for i in range(n):
  x-=a[i]
  if x>=0 and i<n-1:
      count+=1
  elif x==0 and i==n-1:
      count+=1
  
print(count)

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

cnt = 0
for i in range(n):
    min_a = min(a)
    a.remove(min_a)
    if x < min_a:
        break
    x -= min_a
    cnt += 1

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

print(cnt)

Solution (Python):

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

if sum(ai)<x:
    print(n-1)
elif sum(ai)==x:
    print(n)
else:
    divi = 0
    for k in range(n):
        if divi + ai[k] > x:
            print(k)
            break
        divi += ai[k]

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

print(ans)

Solution (Python):
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
n = list1[0]
x = list1[1]
count = 0

for i in range(n):
    if i == n - 1:
        if x == min(list2):
            count = count + 1
        else:
            break
    elif x >= min(list2):
        x = x - min(list2)
        list2.remove(min(list2))
        count = count + 1
    else:
        break
print(count)

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

Solution (Python):
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
    elif x>=a[i]:
        x=x-a[i]
        count+=1
print(count)

Solution (Python):
N,X = map(int,input().split())
src = list(map(int,input().split()))
src.sort()

x = 0
ans = 0
for a in src:
    if x+a > X: break
    ans += 1
    x += a
if x != X and ans == N:
    ans -= 1
print(ans)

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
cnt = 0
s = x
for i in range(N):
    if i == N - 1:
        if s == a[i]:
            cnt += 1
        break
    s -= a[i]
    if s < 0:
        break
    elif s == 0:
        cnt += 1
        break
    else:
        cnt += 1

print(cnt)

Solution (Python):
n,x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
count=0
i=0
while x>0 and i<n:
    x-=a[i]
    if x>=0:count+=1
    i+=1 
if x!=0 and count==n:count-=1
print(count)

Solution (Python):
def solve(N, x, A):
    A = sorted(A)
    count = 0
    for i, a in enumerate(A):
        x -= a
        if i == len(A) - 1:
            if x == 0:
                count += 1
        elif x >= 0:
            count += 1
        else:
            break
    return count

if __name__ == "__main__":
    l = input()
    N, x = int(l.split()[0]),int(l.split()[1])
    A = [int(c) for c in input().split()]
    print(solve(N, x, A))

Solution (Python):
n, x = map(int, input().split())
aa = list(map(int, input().split()))
aa.sort()

ans = 0

for a in aa:
    if x >= a:
        ans += 1
    x -= a

if x > 0:
    ans -= 1

print(ans)

Solution (Python):
import sys
n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))

if min(a) > x:
    print(0)
    sys.exit()

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

a.sort()
l = 0
for i,s in enumerate(a):
  l += s
  if l > x:
    print(i)
    sys.exit()
print(n-1)

Solution (Python):
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:
        ans = i
        break
else:
    if x!=0:
        print(N-1)
    else:
        print(N)
    exit()
print(ans)

Solution (Python):
N, x = map(int, input().split())
l = sorted(map(int, input().split()))

cnt = 0
finished = True

for i in l:
    if i <= x:
        x -= i
        cnt += 1
    else:
        finished = False
        break

if finished and x:
    cnt -= 1

print(cnt)

Solution (Python):
import sys
N,x=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
y=x
ans=0
if A[0]>y:
    print(0)
    sys.exit()
for i in range(N):
    if y<A[i]:
        print(ans)
        sys.exit()
    ans+=1
    y-=A[i]
    
if y!=0:
    ans-=1
print(ans)

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

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

print(count)

Solution (Python):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
sumx=0
i=0
while(i<n):
    if(sumx+arr[i]<=k):
        sumx+=arr[i]
        i+=1
    else:
        break
if(i<n):
    print(i)
elif(i==n and sumx==k):
    print(i)
else:
    print(i-1)

Solution (Python):
N,x = map(int, input().split())
a = list(map(int,input().split()))

sum_a = sum(a)
if sum_a < x:
    print(N-1)
    exit()
elif sum_a == x:
    print(N)
    exit()

rest = sum_a - x
a.sort()
for i in range (N-1, -1, -1):
    rest -= a[i]
    if rest <= 0:
        print(i)
        exit()
print(0)

Solution (Python):
N, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
count=0
for a in A:
	x-=a
	if x >= 0:
		count+=1
	else:
		break
if x > 0:
	count-=1
print(count)

Solution (Python):
def inpl(): return list(map(int, input().split()))

N, x = inpl()
a = inpl()
a = sorted(a)
ans = 0
for ai in a:
    if x>=ai:
        x -= ai
        ans += 1
    else:
        break
else:
    if x!=0:
        ans -= 1
print(ans)

Solution (Python):
N, x = [int(n) for n in input().split()]
As = [int(n) for n in input().split()]

sAs = sorted(As)

c = 0
for i in range(len(sAs)):
    if x >= sAs[i]:
        x -= sAs[i]
        sAs[i] = 0
        c += 1

if all([n == 0 for n in sAs]) and x != 0:
    c -= 1

print(c)

Solution (Python):
N, num = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
sum = 0
for count, i in enumerate(a):
    sum+= i
    if sum > num:
        print(count)
        exit()
if sum == num:
    print(N)
else:
    print(N-1)

Solution (Python):
N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a.sort()
count = 0
cur = 0
for i in range(N):
    cur += a[i]
    if x < cur:
        break
    elif i == N - 1:
        if cur == x:
            count += 1
    else:
        count += 1

print(count)

Solution (Python):
N,x = map(int, input().split())
lis = [int(i) for i in input().split()]
lis.sort()
s = 0
ans = 0
for nums in lis:
  if x >= nums:
    x += -nums
    ans += 1
if ans == N and x != 0:
  ans = ans-1
print(ans)

Solution (Python):
N,x=map(int,input().split())
a=sorted(map(int,input().split()))

v,c=0,0
for (i,j) in enumerate(a):
  if x>=j:
    x-=j
    c+=1
    if i==N-1 and x>0:
      c-=1
print(c)

Solution (Python):
N, x = map(int, input().split())
a_list = list(map(int, input().split()))

a_list.sort()
sum_num = 0
for i in range(N):
    item = a_list[i]
    if x >= item:
        if i != N-1:
            sum_num += 1
            x -= item
        elif x == item:
            sum_num += 1
            x -= item
    else:
       break
print(sum_num)

Solution (Python):
N,x=map(int,input().split())
nums = list(map(int,input().split()))
nums.sort()
if sum(nums) == x:
  print(N)
  exit()
for i in range(N):
  if nums[i] <= x:
    x -= nums[i]
  else:
    print(i)
    exit()
print(N-1)

Solution (Python):
n, x = map(int, input().split())
n -= 1
a = list(map(int, input().split()))
a.sort()
ans = 0
for i, ai in enumerate(a):
    if x < ai:
        break
    elif i == n and  x != ai:
        break
    x -= ai
    ans += 1

print(ans)

Solution (Python):
n,x=map(int, input().split(" "))
A=list(map(int, input().split(" ")))
A.sort()

result=0
for i in range(len(A)):
    
    if i==len(A)-1:
         if A[i]==x:
             result+=1
    elif A[i]<=x:
        x-=A[i]
        result+=1

    else:
        break
print(result)

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

Solution (Python):
USE_STDIO = False

if not USE_STDIO:
    try: import mypc
    except: pass

def main():
    n, x = map(int, input().split(' '))
    A = list(map(int, input().split(' ')))
    A.sort()
    ans = 0
    for i, a in enumerate(A):
        if a > x: break
        x -= a
        if x == 0 or i != len(A) - 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N,x=list(map(int,input().split()))

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

i=0
ans=0
while x>=0 and i<=N-1:
    x-=a[i]
    ans+=1
    i+=1

if x!=0:
    ans-=1
print(ans)

Solution (Python):
N, x = map(int, input().split())
A = [int(x) for x in input().split()]

def f():
    As = sorted(A)
    s = 0
    for i,a in enumerate(As):
        s += a
        if x < s:
            return i
        if x == s:
            return i + 1
    return N - 1
print(f())

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

A.sort()

ans = 0

fl = True
for i in range(N):
  if A[i] <= X:
    ans += 1
    X -= A[i]
  else:
    fl = False
    break
    
if fl and X > 0:
  ans -= 1
print(ans)

Solution (Python):
N, x = map(int, input().split())
A    = list(map(int, input().split()))

A.sort()

R = 0
F = False

for a in A[:-1]:
    if a <= x:
        R += 1
        x -= a
    else:
        break
        F = True

if A[-1] == x or (A[-1] > x and F == True):
    R += 1

print(R)

Solution (Python):
N, x= map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
cnt = 0
for i, a in enumerate(A):
  if i < N - 1:
    cnt += 1 if x >= a else 0
    x -= min(x, a)
  else:
    cnt += 1 if x == a else 0
print(cnt)

Solution (Python):


def solve(n, x, bs):
    cs = sorted(bs)
    res = 0
    for c in cs:
        if c <= x:
            x -= c
            res += 1
        else:
            break
    if x > 0 and res == n:
        res -= 1
    return res


def main():
    n, x = (int(z) for z in input().split())
    bs = [int(b) for b in input().split()]
    res = solve(n, x, bs)
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):

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

    a = sorted(a)
    ans = 0
    tmp = 0
    for i in a:
        tmp += i
        if tmp <= x:
            ans+=1

    if n == ans:
        if sum(a) != x:
            ans-=1

    print(ans)




if __name__ == "__main__":
        main()

Solution (Python):
n, x = map(int, input().split())
listA = list(map(int, input().split()))
listSum =0
for a in listA:
    listSum+=a

if listSum == x:
    print(n)
elif listSum < x:
    print(n-1)
else:
    listA.sort()
    index =0
    sum =0
    while sum < x+1:
        sum += listA[index]
        index+=1
    print(index-1)

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

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

Solution (Python):
n, x = list(map(int, input().split(" ")))
a = list(map(int, input().split(" ")))

a.sort()

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

if(x > 0): ans -= 1

print(ans)

Solution (Python):




def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ANS = 0
    for a_i in a:
        if a_i <= x:
            ANS += 1
            x -= a_i
        else:
            print(ANS)
            return
    if x != 0:
        ANS -= 1
    print(ANS)

if __name__ == '__main__':
    main()

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

sum_a = 0
for i in range(n):
    sum_a += a[i]

if sum_a == x:
    print(n)
elif sum_a < x:
    print(n - 1)
else:
    a.sort()
    count = 0
    while True:
        if x >= a[count]:
            x -= a[count]
            count += 1
        else:
            break
    print(count)

Solution (Python):

from sys import stdin

in_strings = lambda: stdin.readline()[:-1] 
in_int = lambda: int(stdin.readline()) 
in_intlist = lambda: list(map(int, stdin.readline().split())) 

N, X = in_intlist()
a_list = in_intlist()

a_list.sort()

flag = 1
dist = 0
count = 0
for i in range(N):
    dist += a_list[i]
    if dist <= X:
        count += 1
    else:
        flag = 0
        break
if flag and (dist < X):
    count -= 1

print(count)

Solution (Python):
a = list(map(int,input().split()))

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

b.sort()

su = 0

for i in range(a[0]):
	if i == a[0]-1 and (a[1] > b[i] or a[1] < b[i]):break
	elif a[1] >= b[i]:
		su += 1
		a[1] -= b[i]
	else:
		break
print(su)

Solution (Python):
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:
        x = 0
        break
if x > 0:
    cnt -= 1
print(cnt)

Solution (Python):
n, x = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

ans = 0
if sum(a) == x:
    ans = len(a)
elif sum(a) < x:
    ans = len(a) - 1
else:
    a.sort()
    for v in a:
        if v <= x:
            x -= v
            ans += 1
        else:
            break

print(ans)

Solution (Python):

import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


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


a.sort()


i = 0
s = 0
while (i<N) and (s <= x):
    s += a[i]
    i += 1


if i == N:
    if sum(a) == x:
        print(N)
    else:
        print(N-1)
else:
    print(i-1)

Solution (Python):


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


c=0
for i in range(n):
    c+=a[i]

    if c > x:
        break
if c==x:
    i+=1

print(i)

Solution (Python):
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
for i in range(N):
    x -= a[i]
    if x < 0:
        print(i)
        exit()
if x == 0:
    print(N)
else:
    print(N - 1)

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)<x:
    a.sort(reverse=True)
else:
    a.sort()
c=0
for t in a:
    x-=t
    if x<0:break
    c+=1
if x>0:
    print(c-1)
else:
    print(c)

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,x]=i2()
a=i2()
a.sort()
b=0
for i in range(n):
 x-=a[i]
 if x<0:
    break
 b+=1
if x>0 and b==n:
   print(b-1)
else:
   print(b)

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

Solution (Python):
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
t = 0
for i in range(n):
    t += a[i]
    if t > x:
        print(i)
        break
else:
    if sum(a) == x:
        print(n)
    else:
        print(n-1)

Solution (Python):
ri = lambda: list(map(int,input().split()))

n,x = ri()
a = sorted(ri())
ans = 0
c = 0
for i in a:
    c += i
    if c>x:
        break
    ans += 1
if c<x: ans -= 1
print(ans)

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

Solution (Python):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0

if x > sum(a):
    ans = N-1
else:
    for b in a:
        if x >= b:
            x -= b
            ans += 1

print(ans)

Solution (Python):
N, x = map( int, input().split())
A = list( map( int, input().split()))
ans = 0
Sums = 0
A.sort()
for i in range(N-1):
    Sums += A[i]
    if Sums > x:
        break
    ans += 1
Sums += A[N-1]
if Sums == x:
    ans += 1
print(ans)

Solution (Python):
n, amount = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

ans = 0
for ai in a:
    if ai <= amount:
        amount -= ai
        ans += 1

if amount > 0 and ans == n:
    ans -= 1
print(ans)