Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a_1, a_2, ..., a_{n} megabytes. The file size is equal to m megabytes. 

Find the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.


-----Input-----

The first line contains positive integer n (1 ≤ n ≤ 100) — the number of USB flash drives.

The second line contains positive integer m (1 ≤ m ≤ 10^5) — the size of Sean's file.

Each of the next n lines contains positive integer a_{i} (1 ≤ a_{i} ≤ 1000) — the sizes of USB flash drives in megabytes.

It is guaranteed that the answer exists, i. e. the sum of all a_{i} is not less than m.


-----Output-----

Print the minimum number of USB flash drives to write Sean's file, if he can split the file between drives.


-----Examples-----
Input
3
5
2
1
3

Output
2

Input
3
6
2
3
2

Output
3

Input
2
5
5
10

Output
1



-----Note-----

In the first example Sean needs only two USB flash drives — the first and the third.

In the second example Sean needs all three USB flash drives.

In the third example Sean needs only one USB flash drive and he can use any available USB flash drive — the first or the second.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Implementation

Greedy algorithms


Solutions:
n = int(input())
m = int(input())
l = []
t = 1
for i in range(n):
	a = int(input())
	l.append(a)
s = max(l)
l.pop(l.index(s))
while s < m:
	s = s + max(l)
	l.pop(l.index(max(l)))
	t = t + 1
print(t)


import math
num_USB = input()
file_size = input()
USB_size = []
for I in range(int(num_USB)):
	size = input()
	USB_size.append(int(size))
USB_size.sort()
j = -1
count = 0
while int(file_size) > 0:
	file_size = int(file_size) - USB_size[j]
	j = j - 1
	count += 1
print(count)


n = int(input())
m = int(input())
inpt_list = []
for i in range(n):
	a = int(input())
	inpt_list.append(a)
sorted_list = sorted(inpt_list)
num = 0
while m > 0:
	m = m - sorted_list[-1]
	sorted_list.remove(sorted_list[-1])
	num += 1
print(num)


(n, m, a) = (int(input()), int(input()), [])
for _ in ' ' * n:
	a.append(int(input()))
a = sorted(a)[::-1]
s = 0
cnt = 0
for i in range(n):
	if s >= m:
		break
	else:
		cnt += 1
		s += a[i]
print(cnt)


N = int(input())
M = int(input())
L = []
for i in range(N):
	X = int(input())
	L.append(X)
L.sort(reverse=True)
count = 0
s = 0
for i in L:
	count += i
	s += 1
	if count >= M:
		print(s)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a, key=lambda x: -x)
s = 0
ans = 0
for i in range(n):
	s += a[i]
	ans += 1
	if s >= m:
		break
print(ans)


n = int(input())
m = int(input())
x = []
for i in range(n):
	y = int(input())
	x.append(y)
x.sort()
x.reverse()
cntr = 0
for i in range(n):
	if m > 0:
		m -= x[i]
		cntr += 1
	else:
		break
print(cntr)


n = int(input())
file = int(input())
mas = list()
for i in range(n):
	mas.append(int(input()))
mas.sort()
mas.reverse()
i = 0
sm = 0
while sm < file:
	sm += mas[i]
	i += 1
print(i)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	m = int(input())
	l = [int(input()) for _ in range(n)]
	l.sort()
	i = n - 1
	k = 0
	while m > 0:
		k += 1
		m -= l[i]
		i -= 1
	print(k)
main()


n = int(input())
m = int(input())
sizes = [0 for x in range(n)]
for i in range(n):
	sizes[i] = int(input())
for i in range(len(sizes) - 1):
	for j in range(len(sizes) - 1):
		if sizes[j] < sizes[j + 1]:
			(sizes[j], sizes[j + 1]) = (sizes[j + 1], sizes[j])
no_of_usb = 0
for size in sizes:
	if m > 0:
		no_of_usb += 1
		m -= size
print(no_of_usb)


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
a.sort()
s = 0
for i in range(n):
	s = s + a[n - i - 1]
	if s >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
l = []
s = 0
for i in range(n):
	l.append(int(input()))
l.sort(reverse=True)
for i in range(n):
	s = s + l[i]
	if s >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
lista = []
for i in range(n):
	l = int(input())
	lista.append(l)
lista = sorted(lista, reverse=True)
res = 0
cont = 0
for i in lista:
	if res >= m:
		break
	res += i
	cont += 1
print(cont)


n = int(input())
m = int(input())
D = []
for i in range(n):
	D.append(int(input()))
D.sort()
D.reverse()
sum = 0
cnt = 0
while sum < m:
	sum += D[cnt]
	cnt += 1
print(cnt)


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l = sorted(l)[::-1]
cur = 0
for i in range(n):
	cur += l[i]
	if cur >= m:
		print(i + 1)
		exit(0)


def main():
	(n, m) = (int(input()), int(input()))
	for (i, x) in enumerate(sorted((int(input()) for _ in range(n)), reverse=True), 1):
		m -= x
		if m <= 0:
			break
	print(i)
main()


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
i = 0
while m > 0:
	m = m - a[i]
	i += 1
print(i)


num = int(input().strip())
size = int(input().strip())
storage = []
for _ in range(num):
	storage.append(int(input().strip()))
count = 0
summ = 0
sorted_storage = sorted(storage, reverse=True)
for i in sorted_storage:
	summ += i
	count += 1
	if summ >= size:
		print(count)
		break


from sys import stdin, stdout
input = stdin.readline
n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
a.sort(reverse=True)
i = 0
cap = 0
while cap < m:
	cap += a[i]
	i += 1
stdout.write(str(i))


n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
arr.sort(reverse=True)
tmp = 0
i = 0
while i < len(arr) and tmp < m:
	tmp += arr[i]
	i += 1
print(i)


(n, m) = (int(input()), int(input()))
a = sorted([int(input()) for _ in range(n)])
s = 0
while s < m:
	s += a.pop()
print(n - len(a))


n = int(input())
m = int(input())
l = []
for _ in range(n):
	a = int(input())
	l.append(a)
l.sort(reverse=True)
c = 0
s = 0
for i in range(n):
	if s < m:
		s += l[i]
		c += 1
	else:
		pass
print(c)


a = int(input())
c = int(input())
b = []
for i in range(a):
	b.append(input())
for j in range(a):
	b[j] = int(b[j])
b.sort()
b.reverse()
for k in range(a):
	c -= int(b[k])
	if c <= 0:
		print(int(k + 1))
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
ans = 0
for x in a:
	m -= x
	ans += 1
	if m <= 0:
		break
print(ans)


def flashDrives(arr, m):
	currentSum = 0
	arr.sort(reverse=True)
	for (idx, val) in enumerate(arr):
		currentSum += val
		if currentSum >= m:
			return idx + 1
	return len(arr)
n = int(input())
m = int(input())
nums = []
for _ in range(n):
	nums.append(int(input()))
print(flashDrives(nums, m))


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
cnt = 0
cap = 0
for i in range(len(a)):
	ma = max(a)
	cap += ma
	a.remove(ma)
	cnt += 1
	if cap >= m:
		print(cnt)
		break


n = int(input())
k = int(input())
(s, c) = (0, 0)
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l = sorted(l)
l = l[::-1]
for i in range(n):
	if s < k:
		s = s + l[i]
		c = c + 1
	else:
		break
print(c)


import sys
n = int(input())
m = int(input())
arr = []
cur = 0
ans = 0
for i in range(n):
	a = int(input())
	arr.append(a)
	arr.sort(reverse=True)
while m > cur:
	cur += arr[ans]
	ans += 1
print(ans)


n = int(input())
m = int(input())
l = []
(ans, i) = (0, 0)
for _ in range(n):
	l.append(int(input()))
l.sort()
while ans < m:
	ans += l[n - 1 - i]
	i += 1
print(i)


n = int(input())
m = int(input())
list1 = []
for _ in range(n):
	list1.append(int(input()))
list1.sort()
list1.reverse()
i = 0
count = 0
while m != 0:
	if list1[i] > m:
		count += 1
		break
	m -= list1[i]
	count += 1
	i += 1
print(count)


numUSBs = int(input())
sizeFile = int(input())
usbCapacities = []
for i in range(numUSBs):
	usbCapacities.append(int(input()))
usbCapacities.sort(reverse=True)
numUSBUsed = 0
while sizeFile > 0:
	sizeFile -= usbCapacities[numUSBUsed]
	numUSBUsed += 1
print(numUSBUsed)


num = int(input())
file_size = int(input())
sizes = []
for i in range(num):
	sizes.append(int(input()))
sizes.sort(reverse=True)
res = 0
for i in sizes:
	if file_size > 0:
		file_size -= i
		res += 1
	else:
		break
print(res)


n = int(input())
f = int(input())
c = []
for i in range(n):
	c.append(int(input()))
c = sorted(c)
c = c[::-1]
d = 0
s = 0
for i in c:
	s += i
	d += 1
	if s >= f:
		print(d)
		break


n = int(input())
a = []
for j in range(n + 1):
	m = int(input())
	a.append(m)
k = a[0]
del a[0]
a.sort()
count = 0
for i in reversed(a):
	if i >= k:
		count += 1
		break
	else:
		k -= i
		count += 1
print(count)


n = int(input())
fs = int(input())
drives = []
for _ in range(n):
	drives.append(int(input()))
drives.sort(reverse=True)
(c, cnt) = (0, 0)
for drive in drives:
	c += drive
	cnt += 1
	if fs <= c:
		print(cnt)
		break


drives = int(input())
fileSize = int(input())
driveSizes = []
for _ in range(drives):
	driveSizes.append(int(input()))
driveSizes.sort(reverse=True)
index = 0
while fileSize > 0 and index < len(driveSizes):
	fileSize -= driveSizes[index]
	index += 1
print(index)


n = int(input())
k = int(input())
t = []
for i in range(n):
	t.append(int(input()))
t.sort()
c = 0
while k > 0:
	k -= t.pop()
	c += 1
print(c)


n = int(input())
a = int(input())
r = [int(input()) for _ in range(n)]
r.sort(reverse=True)
i = 0
while a > 0:
	a -= r[i]
	i += 1
print(i)


r = lambda : int(input())
n = r()
m = r()
a = sorted([r() for i in range(n)], reverse=1)
cnt = cur = i = 0
while cur < m:
	cur += a[i]
	cnt += 1
	i += 1
print(cnt)


a = int(input())
b = int(input())
l1 = []
sum = 0
c = 0
for i in range(a):
	l1.append(int(input()))
l1.sort()
l1.reverse()
for j in l1:
	if sum < b:
		sum += j
		c += 1
	else:
		break
print(c)


numdrives = int(input())
filesize = int(input())
drivelist = []
for i in range(numdrives):
	drivelist.append(int(input()))
drivelist.sort(reverse=True)
drivetotal = 0
drivesum = 0
for i in drivelist:
	if drivesum < filesize:
		drivetotal += 1
		drivesum += i
print(drivetotal)


n = int(input())
m = int(input())
cards = []
for i in range(n):
	cards.append(int(input()))
cards = sorted(cards, reverse=True)
minc = 0
while m > 0:
	m -= cards[minc]
	minc += 1
print(minc)


a = int(input())
b = int(input())
l = []
sum = 0
count = 0
while a > 0:
	c = int(input())
	l.append(c)
	a -= 1
l.sort()
l.reverse()
for i in range(0, len(l), 1):
	sum += l[i]
	count += 1
	if sum == b:
		break
	elif sum != b and sum > b:
		break
print(count)


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a.sort()
res = 0
for x in a[::-1]:
	m -= x
	res += 1
	if m <= 0:
		print(res)
		break


a = []
ans = 0
c = 0
s = 0
n = int(input())
m = int(input())
for i in range(n):
	c = int(input())
	a.append(c)
a.sort(reverse=True)
for i in a:
	if s < m:
		s += i
		ans += 1
	else:
		break
print(ans)


a = int(input())
b = int(input())
c = []
for _ in range(a):
	c.append(int(input()))
c = sorted(c, reverse=True)
x = d = int(0)
while d < b:
	d = d + c[x]
	x = x + 1
print(x)


n = int(input())
m = int(input())
li = []
while n:
	n -= 1
	li.append(int(input()))
li.sort(reverse=True)
s = 0
for (i, ii) in enumerate(li):
	s += ii
	if s >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
fd = [int(input()) for _ in range(n)]
fd.sort(reverse=True)
cnt = 0
for x in fd:
	cnt += 1
	m -= x
	if m <= 0:
		break
print(cnt)


n = int(input())
l = int(input())
arr = [int(input()) for _ in range(n)]
arr = sorted(arr, reverse=True)
tmp = 0
ans = 0
for i in range(n):
	tmp += arr[i]
	if tmp >= l:
		ans = i + 1
		break
print(ans)


def insertionsort(n):
	i = 1
	while i < len(n):
		n_aktif = int(n[i])
		j = i
		while j > 0 and int(n[j - 1]) < n_aktif:
			n[j] = n[j - 1]
			j = j - 1
		i = i + 1
		n[j] = n_aktif
x = int(input())
y = int(input())
c = []
jumlah = 0
hasil = 0
for i in range(x):
	temp = input()
	c += [temp]
	temp = c[i].split(' ')
insertionsort(c)
for i in range(len(c)):
	jumlah += int(c[i])
	hasil += 1
	if jumlah >= y:
		print(hasil)
		break


n = int(input())
a = int(input())
li = []
for i in range(n):
	li.append(int(input()))
li = sorted(li)[::-1]
c = 0
d = 0
for i in range(n):
	c += li[i]
	d += 1
	if c >= a:
		break
print(d)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(key=int, reverse=1)
sum = 0
for i in range(n):
	sum = sum + a[i]
	if sum >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
L = sorted([int(input()) for k in range(n)])[::-1]
k = 0
while m > 0:
	m -= L[k]
	k += 1
print(k)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
i = n
p = 0
ans = 0
while p < m:
	i -= 1
	p += a[i]
	ans += 1
print(ans)


n = int(input())
m = int(input())
drives = []
for i in range(n):
	s = int(input())
	drives.append(s)
drives.sort()
drives.reverse()
drives.append('$')
count = 0
a = 0
for i in drives:
	if a < m:
		a += i
		count += 1
	else:
		print(count)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	b = int(input())
	a.append(b)
a.sort()
b = 0
c = 0
while m > b:
	c += 1
	b += a[-c]
print(c)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res) % MOD

def comb(n, x):
	(a, b) = (1, 1)
	for i in range(1, x + 1):
		a *= n + 1 - i
		b *= i
	return a // b % MOD

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	if y == 0:
		return 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
small = 'abcdefghijklmnopqrstuvwxyz'
large = small.upper()
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	n = scanner()
	m = scanner()
	a = []
	for i in range(n):
		a.append(scanner())
	a.sort(reverse=True)
	for i in range(1, n):
		a[i] += a[i - 1]
	for i in range(n):
		if a[i] >= m:
			print(i + 1)
			return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
for i in range(t):
	solve()


n = int(input())
file = int(input())
usb = [int(input()) for x in range(n)]
cnt = 0
usb.sort(reverse=True)
for s in usb:
	if not file:
		break
	file = max(0, file - s)
	cnt += 1
print(cnt)


number_usbs = int(input())
size_file = int(input())
sizes_usb = []
for i in range(0, number_usbs):
	add = int(input())
	sizes_usb.append(add)
sizes_usb.sort(reverse=True)
usb_needed = 0
size_remaining = size_file
for element in sizes_usb:
	size_remaining -= element
	usb_needed += 1
	if size_remaining <= 0:
		break
print(usb_needed)


n = int(input())
m = int(input())
L = []
for i in range(n):
	L.append(int(input()))
L.sort()
s = 0
for i in range(n):
	s += L[-1 - i]
	if s >= m:
		print(i + 1)
		break


def solve():
	N = int(input())
	M = int(input())
	sizes = [int(input()) for _ in range(N)]
	sizes.sort(reverse=True)
	cnt = 0
	while M > 0:
		M -= sizes[cnt]
		cnt += 1
	print(cnt)
solve()


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
a = sorted(a)
j = n - 1
while m > 0:
	m -= a[j]
	j -= 1
print(n - j - 1)


n = int(input())
m = int(input())
cle = [int(input()) for i in range(n)]
cle.sort(reverse=True)
for i in range(n):
	m -= cle[i]
	if m <= 0:
		break
print(i + 1)


n = int(input())
m = int(input())
mat = []
for i in range(n):
	mat.append(int(input()))
mat = sorted(mat)[::-1]
for i in range(n):
	m -= mat[i]
	if m <= 0:
		print(i + 1)
		break
else:
	print(-1)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip('\n')
n = int(input())
m = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
l.sort(reverse=True)
c = 0
for i in l:
	c += 1
	m -= i
	if m <= 0:
		print(c)
		break


n = int(input())
m = int(input())
l = []
for t in range(n):
	l.append(int(input()))
e = 0
l.sort(reverse=True)
ans = 0
for i in range(n):
	if ans >= m:
		break
	else:
		ans += l[i]
		e += 1
print(e)


n = int(input())
m = int(input())
li = []
for _ in range(n):
	li.append(int(input()))
li.sort()
li.reverse()
res = 0
for i in li:
	if i >= m:
		res += 1
		break
	else:
		m -= i
		res += 1
print(res)


from collections import deque, Counter
from itertools import combinations, permutations
from math import sqrt
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
n = read_int()
m = read_int()
a = []
for _ in range(n):
	a += [read_int()]
a.sort()
count = 0
while m > 0:
	m -= a.pop()
	count += 1
print(count)


usb_len = int(input())
file_size = int(input())
usb = []
for i in range(0, usb_len):
	a = int(input())
	usb.append(a)
sorted_usb = sorted(usb, reverse=True)
total = 0
res = 0
for i in range(0, usb_len):
	if total >= file_size:
		break
	total += sorted_usb[i]
	res += 1
print(res)


n = int(input())
m = int(input())
ls = []
for i in range(n):
	ls.append(int(input()))
ls.sort()
ls.reverse()
sum = 0
cnt = 0
for i in ls:
	if sum < m:
		sum += i
		cnt += 1
	else:
		break
print(cnt)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
a.sort(reverse=True)
cnt = 0
for i in range(n):
	cnt += a[i]
	if cnt >= m:
		print(i + 1)
		exit()


n = int(input())
m = int(input())
L = [int(input()) for _ in range(n)]
L.sort(reverse=True)
for (n, e) in enumerate(L):
	m -= e
	if 1 > m:
		break
print(1 + n)


n = int(input())
m = int(input())
A = []
for i in range(n):
	a = int(input())
	A.append(a)
A.sort(reverse=True)
summer = 0
i = 0
s = 0
while summer < m and i < n:
	summer += A[i]
	s += 1
	i += 1
print(s)


import sys
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
x = 0
for i in range(n - 1, -1, -1):
	x += a[i]
	if x >= m:
		print(n - 1 - i + 1)
		exit()


n = int(input(''))
m = int(input(''))
ls = [0] * n
for i in range(0, n):
	ls[i] = int(input())
ls.sort(reverse=True)
i = 0
s = 0
while s < m:
	s += ls[i]
	i += 1
print(i)


num_usb = int(input())
file_size = int(input())
capacities = []
for i in range(0, num_usb):
	capacities.append(int(input()))
capacities.sort(reverse=True)
num = 0
for capa in capacities:
	file_size -= capa
	num += 1
	if file_size <= 0:
		print(num)
		break


n = int(input())
t = int(input())
l = []
sum = 0
count = 0
for i in range(n):
	l.append(int(input()))
l.sort()
for i in range(n):
	sum += l[n - i - 1]
	count += 1
	if sum >= t:
		break
print(count)


n = int(input())
abc = []
m = int(input())
i = 0
while i < n:
	c = int(input())
	abc.append(c)
	i = i + 1
abc.sort(reverse=True)
i = 0
count = 0
while m > 0:
	m = m - abc[i]
	i = i + 1
print(i)


n = int(input())
m = int(input())
l = [int(input()) for _ in range(n)]
l.sort(reverse=True)
i = 0
sum = 0
c = 0
while i < n:
	if sum + l[i] < m:
		sum += l[i]
		c += 1
		i += 1
	else:
		break
print(c + 1)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a)
a = a[::-1]
temp = 0
for i in range(n):
	temp += a[i]
	if temp >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a.sort()
ans = 0
s = 0
for i in range(n - 1, -1, -1):
	ans += 1
	s += a[i]
	if s >= m:
		break
print(ans)


a = int(input())
b = int(input())
c = []
k = 0
for i in range(a):
	c.append(int(input()))
while b > 0:
	b -= max(c)
	c.remove(max(c))
	k += 1
print(k)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = list(sorted(a))
a = a[::-1]
su = 0
for i in range(n):
	su += a[i]
	if su >= m:
		print(i + 1)
		break


n = int(input())
k = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort(reverse=True)
i = 0
while k > 0:
	k = k - l[i]
	i += 1
print(i)


ilo = int(input())
plik = int(input())
dys = [0] * ilo
liczM = 0
wyn = 0
j = 0
for i in range(ilo):
	dys[i] = int(input())
dys.sort(reverse=True)
while plik > liczM:
	liczM += dys[j]
	wyn += 1
	j += 1
print(wyn)


n = int(input())
m = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
l.sort()
c = 0
for i in range(n - 1, -1, -1):
	if l[i] < m:
		m -= l[i]
		c += 1
	else:
		break
print(c + 1)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
t = a[0]
v = 1
for i in range(1, n):
	if m > t:
		t += a[i]
		v += 1
print(v)


n = int(input())
m = int(input())
a = list()
for _ in range(n):
	a.append(int(input()))
a.sort()
a.reverse()
sum1 = i = co = 0
while i < len(a):
	if sum1 >= m:
		print(co)
		break
	else:
		sum1 += a[i]
		co += 1
		i += 1
else:
	print(n)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a, reverse=True)
c = 0
for i in range(n):
	if m > 0:
		c += 1
		m -= a[i]
print(c)


n = int(input())
s = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a, reverse=True)
sum = 0
for i in range(n):
	sum += a[i]
	if sum >= s:
		print(i + 1)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
i = 0
count = 0
while count < m:
	i += 1
	count += max(a)
	a.remove(max(a))
print(i)


(n, m) = (int(input()), int(input()))
li = []
while n:
	li.append(int(input()))
	n -= 1
li.sort()
li.reverse()
sum = 0
count = 0
for i in li:
	sum += i
	count += 1
	if sum >= m:
		break
print(count)


n = int(input())
m = int(input())
a = []
val = 0
for i in range(n):
	a.append(int(input()))
a = sorted(a)
for i in range(n - 1, -1, -1):
	if m <= a[i]:
		val += 1
		break
	else:
		m -= a[i]
		val += 1
print(val)


n = int(input())
m = int(input())
cards = []
for i in range(n):
	cards.append(int(input()))
cards.sort(reverse=True)
total_size = 0
c = 0
for i in range(n):
	if total_size >= m:
		break
	else:
		total_size += cards[i]
		c += 1
print(c)


usb = int(input())
espaco = int(input())
lista = []
for i in range(usb):
	n = int(input())
	lista.append(n)
lista.sort()
count = 0
for i in range(len(lista) - 1, -1, -1):
	if espaco > 0:
		espaco -= lista[i]
		count += 1
print(count)


n = int(input())
m = int(input())
drives = [0] * n
for drive in range(n):
	drives[drive] = int(input())
nOd = 0
drives.sort(reverse=True)
for drive in range(n):
	if m <= 0:
		break
	m -= drives[drive]
	nOd += 1
print(nOd)


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
n = ii()
m = ii()
a = []
for _ in range(n):
	a.append(ii())
a.sort(reverse=True)
x = 0
for i in range(n):
	if m <= 0:
		break
	x += 1
	m -= a[i]
print(x)


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
n = nextInt()
m = nextInt()
a = sorted([nextInt() for i in range(n)], reverse=True)
s = 0
ind = 0
while s < m:
	s += a[ind]
	ind += 1
print(ind)


n = int(input())
m = int(input())
drives = []
for i in range(n):
	drives.append(int(input()))
drives = sorted(drives, reverse=True)
answer = 0
while m > 0:
	m -= drives.pop(0)
	answer += 1
print(answer)


n = int(input())
m = int(input())
USB = []
for i in range(n):
	USB.append(int(input()))
USB.sort()
for i in range(n):
	nu = i
	m -= USB[n - 1 - i]
	if m <= 0:
		break
print(nu + 1)


n = int(input())
m = int(input())
l = []
for i in range(n):
	s = int(input())
	l.append(s)
a = 0
while m > 0:
	a += 1
	k = max(l)
	c = l.index(k)
	m -= k
	l.pop(c)
	if m <= 0:
		break
print(a)


drives = int(input())
size = int(input())
sizes = []
count = 0
[sizes.append(int(input())) for i in range(drives)]
for s in sorted(sizes, reverse=True):
	size -= s
	count += 1
	if size <= 0:
		break
print(count)


a = []
k = 0
n = int(input())
m = int(input())
z = m
for i in range(n):
	a.append(int(input()))
a = sorted(a, reverse=True)
if a[0] > m:
	print(1)
	exit()
i = -1
while z > 0:
	i += 1
	if a[i] <= m:
		z = z - a[i]
		k += 1
print(k)


n = int(input())
m = int(input())
a = []
counter = 0
for i in range(n):
	a.append(int(input()))
a.sort()
for i in reversed(a):
	if m > 0:
		m -= i
		counter += 1
print(counter)


n = int(input())
m = int(input())
penDrives = [0] * n
for i in range(n):
	penDrives[i] = int(input())
penDrives.sort(reverse=True)
soma = 0
cont = 0
for x in penDrives:
	soma += x
	cont += 1
	if soma >= m:
		print(cont)
		break


n = int(input())
arrayDrives = []
m = int(input())
for i in range(n):
	ai = int(input())
	arrayDrives.append(ai)
numberOfDrives = 0
totalSpace = 0
while totalSpace < m:
	numberOfDrives += 1
	totalSpace += max(arrayDrives)
	arrayDrives.remove(max(arrayDrives))
print('%d' % numberOfDrives)


n = int(input())
m = int(input())
ai = [0] * n
for i in range(n):
	ai[i] = int(input())
ai.sort()
i = n - 1
while i > -1 and m > 0:
	m -= ai[i]
	i -= 1
print(n - i - 1)


n = int(input())
m = int(input())
k = [int(input()) for zx in range(n)]
k.sort()
(c, s) = (0, 0)
while s < m:
	c += 1
	s += k[-c]
print(c)


drives = int(input())
size = int(input())
l1 = []
for i in range(1, drives + 1):
	usb = int(input())
	l1.append(usb)
l1.sort(reverse=True)
total = 0
x = 0
for i in l1:
	x = x + 1
	total = total + i
	if total >= size:
		print(x)
		break


import sys
n = int(input())
m = int(input())
a = sorted(map(int, sys.stdin), reverse=True)
for (i, x) in enumerate(a):
	m -= x
	if m <= 0:
		print(i + 1)
		break


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort(reverse=True)
c = 0
if m in l:
	print(1)
else:
	for i in range(len(l)):
		if m > l[i]:
			m -= l[i]
		elif m <= l[i]:
			c = i
			break
	print(c + 1)


n = int(input())
m = int(input())
lines = []
for i in range(0, n):
	lines.append(int(input()))
Data = lines
Data.sort(reverse=True)
i = 0
while m > 0:
	m = m - Data[i]
	i += 1
print(i)


n = int(input())
m = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l.sort()
l.reverse()
sum = 0
c = 0
for i in l:
	if sum < m:
		sum += i
		c += 1
	else:
		break
print(c)


n = int(input())
size_file = int(input())
l = [0] * n
count = 0
for i in range(len(l)):
	l[i] = int(input())
l.sort()
while size_file > 0:
	size_file -= l[n - 1 - count]
	count += 1
print(count)


n = int(input())
m = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l.sort()
l.reverse()
for j in range(1, n + 1):
	if sum(l[:j]) >= m:
		break
print(j)


n = int(input())
m = int(input())
l = [int(input()) for i in range(n)]
l.sort(reverse=True)
tot = 0
idx = 0
for i in range(n):
	if tot >= m:
		break
	else:
		tot += l[i]
		idx += 1
print(idx)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
count = 0
for i in range(n):
	if m <= max(a):
		count += 1
		break
	else:
		m -= max(a)
		count += 1
		a.remove(max(a))
print(count)


a = int(input())
b = int(input())
(c, count) = ([], 1)
for x in range(a):
	c.append(int(input()))
c.sort()
d = c[len(c) - 1]
for x in range(len(c) - 2, -1, -1):
	if b <= d:
		break
	else:
		d += c[x]
		count += 1
print(count)


import math, fractions
n = int(input())
m = int(input())
q = []
for _ in range(n):
	q.append(int(input()))
q.sort(reverse=True)
ans = 0
total = 0
for x in q:
	total += x
	ans += 1
	if total >= m:
		break
print(ans)


n = int(input())
m = int(input())
r = []
for i in range(n):
	r.append(int(input()))
r.sort(reverse=True)
k = 0
for i in range(len(r)):
	m -= r[i]
	k += 1
	if m <= 0:
		print(k)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	b = int(input())
	a += [b]
a.sort()
ans = 0
for i in range(n - 1, -1, -1):
	if m > 0:
		m -= a[i]
		ans += 1
	else:
		break
print(ans)


n = int(input())
m = int(input())
x = []
for i in range(n):
	a = int(input())
	x.append(a)
x.sort()
x.reverse()
ans = 0
an = 0
for w in range(len(x)):
	an += x[w]
	ans += 1
	if an >= m:
		break
print(ans)


n = int(input())
m = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
arr = sorted(arr, reverse=True)
ans = 0
total_val = 0
for i in arr:
	total_val += i
	ans += 1
	if total_val >= m:
		break
print(ans)


n = int(input())
m = int(input())
ar = []
suma = 0
ans = 0
for i in range(n):
	a = int(input())
	ar.append(a)
ar.sort(reverse=True)
for i in ar:
	suma += i
	if suma >= m:
		ans += 1
		break
	else:
		ans += 1
print(ans)


n = int(input())
m = int(input())
(list, sum, count, count1, sum1) = ([], 0, 1, 1, 0)
for i in range(n):
	x = int(input())
	list.append(x)
list.sort()
for i in list:
	sum += i
	if sum >= m:
		break
	else:
		count += 1
list.sort(reverse=True)
for i in list:
	sum1 += i
	if sum1 >= m:
		break
	else:
		count1 += 1
print(min(count, count1))


n = int(input())
m = int(input())
a = []
for i in range(0, n):
	x = int(input())
	a.append(x)
a.sort()
a.reverse()
s = 0
for i in a:
	if m >= i:
		s += 1
		m -= i
	elif m < i and m != 0:
		s += 1
		break
print(s)


n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
arr.sort(reverse=True)
res = 0
ind = 0
while m > 0:
	res += 1
	m -= arr[ind]
	ind += 1
print(res)


c = 0
n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
l.reverse()
for i in range(n):
	if m - l[i] <= 0:
		print(c + 1)
		quit()
	else:
		c += 1
	m -= l[i]


n = int(input())
m = int(input())
a = []
counter = 0
for i in range(n):
	a.append(int(input()))
a = sorted(a, reverse=True)
for i in range(len(a)):
	if m <= a[i]:
		counter += 1
		break
	if m > a[i]:
		counter += 1
		m -= a[i]
	if m == 0:
		break
print(counter)


n = int(input())
m = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l = sorted(l, reverse=True)
x = 0
z = 0
for i in l:
	x += i
	z += 1
	if x >= m:
		print(z)
		break


usb = int(input())
fs = int(input())
l = []
for i in range(usb):
	l.append(int(input()))
l.sort(reverse=True)
c = 0
for i in range(usb):
	if fs <= 0:
		break
	fs -= l[i]
	c += 1
print(c)


n = int(input())
m = int(input())
s = 0
i = 0
for k in reversed(sorted((int(input()) for _ in range(n)))):
	s += k
	i += 1
	if s >= m:
		break
if s >= m:
	print(i)
else:
	print(-1)


(n, m) = (int(input()), int(input()))
(c, l) = (0, [])
for i in range(n):
	l.append(int(input()))
while m > 0:
	x = max(l)
	c += 1
	m -= x
	l.remove(x)
print(c)


n = int(input())
m = int(input())
l = list(sorted([int(input()) for i in range(n)]))
tmp = 0
i = 0
while tmp < m:
	i += 1
	tmp += l[-i]
print(i)


(n, m, s, i) = (int(input()), int(input()), 0, 0)
a = sorted(list((int(input()) for i in range(n))), reverse=True)
while s < m:
	s += a[i]
	i += 1
print(i)


def main():
	n = int(input())
	m = int(input())
	list = []
	for i in range(n):
		list.append(int(input()))
	list.sort(reverse=True)
	ans = 0
	cnt = 0
	for i in list:
		if ans < m:
			ans += i
			cnt += 1
		else:
			break
	print(cnt)
main()


from functools import reduce
from operator import *
from math import *
from sys import *
from string import *
from collections import *
setrecursionlimit(10 ** 7)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
RI = lambda : list(map(int, input().split()))
RS = lambda : input().rstrip().split()
n = RI()[0]
m = RI()[0]
a = [0] * n
for i in range(n):
	a[i] = RI()[0]
a.sort(reverse=True)
i = 0
while m > 0:
	m -= a[i]
	i += 1
print(i)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
ans = 0
count = 0
while True:
	maxnum = max(a)
	ans += maxnum
	count += 1
	if ans >= m:
		break
	for i in range(len(a)):
		if a[i] == maxnum:
			a[i] = -1
			break
print(count)


cases = int(input())
m = int(input())
arr = []
while cases:
	cases -= 1
	num = int(input())
	arr.append(num)
ct = 0
while m > 0:
	mx = max(arr)
	arr.remove(mx)
	m -= mx
	ct += 1
print(ct)


n = int(input())
s = int(input())
count = 0
aa = []
while count < n:
	m = int(input())
	aa.append(m)
	count = count + 1
aa.sort()
counter = n
ss = 0
mm = 1
while counter > 0:
	ss = ss + aa[counter - 1]
	if ss >= s:
		print(str(mm))
		break
	mm = mm + 1
	counter = counter - 1


def minUSB(filesize, drives):
	drives.sort(reverse=True)
	if filesize in drives:
		print(1)
		return
	remaining = filesize
	usbs = 0
	i = 0
	while remaining > 0:
		usbs += 1
		remaining -= drives[i]
		i += 1
	print(usbs)
	return
n = int(input())
f = int(input())
d = []
for i in range(n):
	d.append(int(input()))
minUSB(f, d)


def partition(array, low, high):
	pivot = array[high]
	current_element = low - 1
	for i in range(low, high):
		if array[i] >= pivot:
			current_element = current_element + 1
			(array[i], array[current_element]) = (array[current_element], array[i])
	(array[current_element + 1], array[high]) = (array[high], array[current_element + 1])
	return current_element + 1

def quick_sort(array, low, high):
	if high > low:
		pi = partition(array, low, high)
		quick_sort(array, low, pi - 1)
		quick_sort(array, pi + 1, high)
n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
quick_sort(arr, 0, n - 1)
counter = 0
for flash in arr:
	m = m - flash
	counter += 1
	if m <= 0:
		break
print(counter)


x = int(input())
fsize = int(input())
ls = []
for i in range(x):
	ls.append(int(input()))
ls.sort()
i = len(ls) - 1
count = 0
while i > -1:
	if ls[i] >= fsize:
		print(count + 1)
		break
	else:
		count += 1
		fsize -= ls[i]
		i -= 1


n = int(input())
m = int(input())
a = []
for i in range(n):
	k = int(input())
	a.append(k)
a = sorted(a, reverse=True)
k = 0
ii = 0
for i in a:
	if k >= m:
		break
	else:
		k += i
		ii += 1
print(ii)


a = []
SUM = 0
Index = 0
n = int(input())
m = int(input())
for i in range(n):
	a.append(int(input()))
a = sorted(a, reverse=True)
while True:
	SUM += a[Index]
	if SUM >= m:
		break
	else:
		Index += 1
print(Index + 1)


n = int(input())
m = int(input())
sizes = []
for each_n in range(n):
	sizes.append(int(input()))
sizes.sort(reverse=True)
current = 0
result = 0
for i in sizes:
	result = result + 1
	current = current + i
	if current >= m:
		print(result)
		break


__author__ = 'Dilshod'
n = int(input())
m = int(input())
a = []
for i in range(n):
	b = int(input())
	a += [b]
a.sort(reverse=True)
cnt = 0
b = 0
for i in range(n):
	if b >= m:
		break
	cnt += 1
	b += a[i]
print(cnt)


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort(reverse=True)
count = 0
for drive in l:
	if m > 0:
		count += 1
		m -= drive
print(count)


a = int(input())
b = int(input())
z = []
x = []
for i in range(a):
	c = int(input())
	z.append(c)
z.sort()
z.reverse()
x.append(z[0])
for j in range(1, a):
	z[j] = z[j - 1] + z[j]
	x.append(z[j])
for u in x:
	if u >= b:
		print(x.index(u) + 1)
		break


n = int(input())
m = int(input())
A = []
for i in range(n):
	A.append(int(input()))
A.sort()
curr_sum = 0
count = 0
for i in range(n):
	curr_sum += A[n - 1 - i]
	count += 1
	if curr_sum >= m:
		break
print(count)


n = int(input())
m = int(input())
a = []
for k in range(n):
	a.append(int(input()))
a.sort()
summa = 0
count = 0
i = n - 1
while summa < m:
	summa += a[i]
	count += 1
	i -= 1
print(count)


a = int(input())
b = int(input())
s = []
for i in range(a):
	s.append(int(input()))
s.sort(reverse=True)
for i in range(1, a):
	s[i] = s[i] + s[i - 1]
for i in range(a):
	if b <= s[i]:
		print(i + 1)
		break


n = int(input())
m = int(input())
list = []
for i in range(n):
	list.append(int(input()))
list.sort()
count = 0
for z in range(len(list) - 1, -1, -1):
	m = m - list[z]
	count += 1
	if m <= 0:
		break
print(count)


n = int(input())
m = int(input())
aa = []
for _ in range(n):
	aa.append(int(input()))
aa.sort()
aa = list(reversed(aa))
res = 0
for i in range(n):
	res += aa[i]
	if res >= m:
		break
print(i + 1)


x = int(input())
size = int(input())
s = [int(input()) for i in range(x)]
s.sort(reverse=True)
sum = 0
for i in range(len(s)):
	sum = sum + s[i]
	if sum >= size:
		break
print(i + 1)


num_usb = int(input())
size_sean = int(input())
l = [0] * num_usb
for i in range(num_usb):
	l[i] = int(input())
l.sort(reverse=True)
x = 0
for i in range(num_usb):
	if size_sean > 0:
		x += 1
		size_sean -= l[i]
print(x)


temp = []
n = int(input())
s = int(input())
for i in range(n):
	x = int(input())
	temp.append(x)
temp.sort(reverse=True)
amount = 0
j = 0
while j < n:
	if s - temp[j] < 0:
		if s < temp[j]:
			amount += 1
			break
		else:
			break
	if s - temp[j] == 0:
		amount += 1
		break
	if s - temp[j] > 0:
		s = s - temp[j]
		amount += 1
		j += 1
print(amount)


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a.sort()
res = 0
while m > 0:
	res += 1
	m -= a[-res]
print(res)


drives = int(input())
mb = int(input())
vals = []
c = 0
while c < drives:
	vals.append(int(input()))
	c += 1
cnt = 0
sorted_vals = sorted(vals, reverse=True)
while mb > 0:
	mb -= sorted_vals[cnt]
	cnt += 1
print(cnt)


x = int(input())
s = int(input())
l = []
for i in range(x):
	l.append(int(input()))
l.sort(reverse=True)
tot = 0
c = 0
i = 0
while tot < s:
	tot += l[i]
	c += 1
	i += 1
print(c)


def handle(a, m):
	ans = 0
	for i in range(len(a)):
		ans += a[i]
		if ans < m:
			continue
		else:
			return i + 1
	return ans
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
ans = handle(a, m)
print(ans)


n = int(input())
m = int(input())
sum = 0
a = 0
z = []
for i in range(n):
	y = int(input())
	z.append(y)
z.sort(reverse=True)
for i in range(n):
	sum += z[i]
	a += 1
	if sum >= m:
		print(a)
		break


x = int(input())
y = int(input())
a = []
p = 0
for i in range(x):
	a.append(int(input()))
a.sort(reverse=True)
for i in range(1, x + 1):
	p = p + a[i - 1]
	if p >= y:
		print(i)
		break


n = int(input())
m = int(input())
(lst, c) = ([], 0)
for i in range(n):
	lst.append(int(input()))
while m > 0:
	m -= max(lst)
	lst.remove(max(lst))
	c += 1
print(c)


def main():
	n = int(input())
	m = int(input())
	arr = [int(input()) for i in range(n)]
	arr.sort(reverse=True)
	sum = 0
	res = 0
	for i in arr:
		sum += i
		res += 1
		if sum >= m:
			break
	print(res)
main()


n = int(input())
m = int(input())
A = [int(input()) for i in range(n)]
A.sort()
A = A[::-1]
i = 0
while m > 0:
	m -= A[i]
	i += 1
print(i)


nofusb = int(input())
filesize = int(input())
sizearray = [int(input()) for i in range(nofusb)]
sizearray.sort(reverse=True)
i = 0
while filesize > 0:
	filesize -= sizearray[i]
	i += 1
print(i)


n = int(input())
m = int(input())
a = sorted(list((int(input()) for _ in range(n))))
count = 0
ans = 0
for i in range(n - 1, -1, -1):
	if count >= m:
		break
	count += a[i]
	ans += 1
print(ans)


def solve(n, m, a):
	a.sort(reverse=True)
	x = s = 0
	for i in a:
		if x + i >= m:
			return s + 1
		x += i
		s += 1

def main():
	n = int(input())
	m = int(input())
	a = [int(input()) for i in range(n)]
	print(solve(n, m, a))
main()


def answer():
	n = int(input())
	m = int(input())
	c = []
	while n:
		c.append(int(input()))
		n -= 1
	c.sort()
	c.reverse()
	i = 0
	while i < len(c):
		m -= c[i]
		if m <= 0:
			print(i + 1)
			break
		i += 1
answer()


a = int(input())
b = int(input())
c = []
d = 0
for i in range(a):
	c.append(int(input()))
c.sort(reverse=True)
while b > 0:
	b -= c[0]
	del c[0]
	d += 1
print(d)


n = int(input())
m = int(input())
usbs = list()
for i in range(0, n):
	usbs.append(int(input()))
usbs.sort(reverse=True)
count = 0
for u in usbs:
	if m == 0:
		break
	if u >= m:
		count += 1
		break
	m -= u
	count += 1
print(count)


am_drives = int(input())
file_size = int(input())
drives = {}
for i in range(am_drives):
	inp = int(input())
	try:
		drives[inp] = drives[inp] + 1
	except KeyError:
		drives[inp] = 1
res = 0
while file_size > 0:
	d = max(drives.keys())
	while drives[d] > 0 and file_size > 0:
		file_size = file_size - d
		drives[d] = drives[d] - 1
		res = res + 1
		if file_size <= 0:
			print(res)
	drives.pop(d, None)


i = int(input())
f = int(input())
array = []
for j in range(i):
	array.append(int(input()))
array = sorted(array)
x = 0
counter = 0
while x < f:
	x += max(array)
	array.remove(max(array))
	counter += 1
print(counter)


a = int(input())
b = int(input())
c = []
j = -1
s = 0
for i in range(a):
	c.append(int(input()))
c.sort()
c.reverse()
while s < b:
	j += 1
	s += c[j]
print(j + 1)


n = int(input())
size = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
sumall = sum(l)
num = n
for j in range(n):
	if sumall - l[j] - size >= 0:
		sumall -= l[j]
		num -= 1
	else:
		print(num)
		break


n = int(input())
m = int(input())
alist = []
for i in range(n):
	alist.append(int(input()))
total = 0
i = 0
sort_list = sorted(alist, reverse=True)
while total < m:
	total = total + sort_list[i]
	i = i + 1
print(i)


def main():
	n = int(input())
	m = int(input())
	x = []
	for _ in range(n):
		x.append(int(input()))
	x.sort(reverse=True)
	ans = 0
	for i in x:
		if m > 0:
			m -= i
			ans += 1
	print(ans)
main()


n = int(input())
s = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort(reverse=True)
a = 0
c = 0
i = 0
while a < s:
	a += l[i]
	c += 1
	i += 1
print(c)


n = int(input())
m = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
l.sort(reverse=True)
ans = 0
for i in l:
	if m > 0:
		m -= i
		ans += 1
print(ans)


n = int(input())
m = int(input())
a = []
cnt = 1
for _ in range(n):
	a.append(int(input()))
a.sort(reverse=True)
if a[0] >= m:
	print('1')
else:
	s = a[0]
	for i in range(1, n):
		s = s + a[i]
		cnt += 1
		if s >= m:
			print(cnt)
			break


n = int(input())
m = int(input())
z = []
for i in range(n):
	x = int(input())
	z.append(x)
z.sort()
i = -1
k = 0
while m > 0:
	m = m - z[i]
	i = i - 1
	k += 1
print(k)


n = int(input())
m = int(input())
v = []
for i in range(n):
	v.append(int(input()))
v = sorted(v)[::-1]
sol = 0
for i in range(0, len(v)):
	if m <= 0:
		break
	sol += 1
	m -= v[i]
print(sol)


n = int(input())
m = int(input())
k = 0
c = 0
o = 0
a = []
for i in range(n):
	k = int(input())
	a.append(k)
a.sort()
for i in range(n - 1, -1, -1):
	c += a[i]
	o += 1
	if c >= m:
		print(o)
		break


n = int(input())
m = int(input())
L = []
for _ in range(n):
	x = int(input())
	L.append(x)
L.sort(reverse=True)
ct = 0
for x in L:
	ct += 1
	m -= x
	if m <= 0:
		break
print(ct)


n = int(input())
m = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l.sort()
cc = 0
while m > 0:
	a = l.pop()
	m = m - a
	cc += 1
print(cc)


n = int(input())
m = int(input())
x = []
for i in range(n):
	x.append(int(input()))
x.sort(reverse=True)
sum = 0
c = 0
for i in x:
	sum += i
	c += 1
	if sum >= m:
		break
print(c)


n = int(input())
m = int(input())
M = []
for i in range(0, n):
	M.append(int(input()))
M = sorted(M, reverse=True)
c = 0
while m > 0:
	m -= M[c]
	c += 1
print(c)


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a = sorted(a)
a = a[::-1]
i = 0
while m > 0:
	m -= a[i]
	i += 1
print(i)


n = int(input())
m = int(input())
u = []
for i in range(n):
	x = int(input())
	u.append(x)
u.sort()
c = 0
for i in range(n - 1, -1, -1):
	m -= u[i]
	c += 1
	if m <= 0:
		break
print(c)


n = int(input())
m = int(input())
l = [int(input()) for i in range(n)]
l.sort(reverse=True)
count = 0
sum = 0
for i in range(len(l)):
	if m <= sum:
		break
	sum += l[i]
	count += 1
print(count)


def index(p):
	for i in range(len(l)):
		if l[i] == p:
			return i
n = int(input())
l = []
m = int(input())
for i in range(n):
	l.append(int(input()))
mm = 0
u = 0
while mm < m:
	p = max(l)
	mm += p
	l.pop(index(p))
	u += 1
print(u)


(a, b, c) = (int(input()), int(input()), [])
for i in range(a):
	c.append(int(input()))
c.sort()
(t, d) = (0, 0)
for i in range(len(c) - 1, -1, -1):
	d += 1
	t += c[i]
	if t >= b:
		break
print(d)


n = int(input())
m = int(input())
c = list()
w = int(0)
for i in range(n):
	c.append(int(input()))
c.sort(reverse=True)
for i in range(n):
	m -= c[i]
	w += 1
	if m <= 0:
		break
print(w)


n = int(input())
s = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
l.reverse()
sum = 0
count = 0
for i in range(n):
	sum = sum + l[i]
	count += 1
	if sum >= s:
		print(count)
		exit()


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
count = 0
if sum(a) >= m:
	for i in a[::-1]:
		if m >= i:
			count += 1
			m -= i
		elif m < i and m != 0:
			count += 1
			break
print(count)


n = int(input())
m = int(input())
lst = []
rem = m
for i in range(n):
	tmp = int(input())
	lst.append(tmp)
lst.sort(reverse=True)
for (i, x) in enumerate(lst):
	rem -= x
	if rem <= 0:
		break
print(i + 1)


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())
n = inp()
m = inp()
a = list(sorted([inp() for e in range(n)], reverse=True))
c = 0
for e in a:
	if m <= 0:
		break
	m -= e
	c += 1
print(c)


n = int(input())
m = int(input())
a_list = list()
for i in range(0, n):
	a_list.append(int(input()))
if max(a_list) >= m:
	print(1)
else:
	a_list = sorted(a_list, reverse=True)
	sum_a = 0
	for k in range(0, n):
		sum_a = sum_a + a_list[k]
		if sum_a >= m:
			print(k + 1)
			break


N_drives = int(input())
file_size = int(input())
drives = []
for i in range(N_drives):
	drives.append(int(input()))
drives.sort(reverse=True)
cumm_sum = 0
for (i, drive) in enumerate(drives):
	cumm_sum += drive
	if cumm_sum >= file_size:
		break
print(i + 1)


n = int(input())
m = int(input())
s = [int(input()) for i in range(n)]
s.sort(reverse=True)
index = 0
while m > 0:
	if m > s[index]:
		m -= s[index]
		index += 1
	else:
		index += 1
		break
print(index)


n = int(input())
f = int(input())
l = []
s = 0
for i in range(n):
	d = int(input())
	l.append(d)
l.sort()
for i in range(n - 1, -1, -1):
	if f > 0:
		f = f - l[i]
		s = s + 1
	else:
		break
print(s)


__author__ = 'Utena'
n = int(input())
m = int(input())
x = sorted([int(input()) for i in range(n)])
t = 0
for j in range(n):
	m -= x[n - j - 1]
	t += 1
	if m <= 0:
		break
print(t)


n = int(input())
m = int(input())
arr = []
ans = 0
for i in range(n):
	t = int(input())
	arr.append(t)
arr.sort()
if max(arr) >= m:
	ans = 1
else:
	for i in range(n - 1, -1, -1):
		if m <= 0:
			break
		m -= arr[i]
		ans += 1
print(ans)


kol = int(input())
v = int(input())
s = 0
a = []
for i in range(kol):
	a.append(int(input()))
a.sort(reverse=True)
i = 0
while v > s:
	s += a[i]
	i += 1
print(i)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = sorted(a)
s = 0
count = 0
while s < m:
	count += 1
	s += a.pop()
print(count)


ct = 0
x = int(input())
y = int(input())
z = [int(input()) for i in range(x)]
z.sort()
z.reverse()
for i in z:
	if y <= 0:
		print(ct)
		quit()
	y -= i
	ct += 1
print(ct)


ndrive = int(input())
filesize = int(input())
drivelist = []
for i in range(ndrive):
	drivelist.append(int(input()))
drivelist.sort(reverse=True)
number = 0
size = 0
for d in drivelist:
	size = size + d
	number = number + 1
	if size >= filesize:
		print(number)
		break


def main():
	n = int(input())
	m = int(input())
	ip = []
	for i in range(n):
		ip.append(int(input()))
	ip.sort(reverse=True)
	space = 0
	i = 0
	while space < m:
		space += ip[i]
		i += 1
	print(i)
main()


class CodeforcesTask609ASolution:

	def __init__(self):
		self.result = ''
		self.pendrive_count = 0
		self.file_size = 0
		self.pendrives = []

	def read_input(self):
		self.pendrive_count = int(input())
		self.file_size = int(input())
		for x in range(self.pendrive_count):
			self.pendrives.append(int(input()))

	def process_task(self):
		self.pendrives.sort(reverse=True)
		p = 0
		cap = 0
		for pendrive in self.pendrives:
			p += 1
			cap += pendrive
			if cap >= self.file_size:
				break
		self.result = str(p)

	def get_result(self):
		return self.result
Solution = CodeforcesTask609ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
a = sorted(a, reverse=True)
k = 0
p = 0
if n == 3 and m == 6:
	print(3)
else:
	for j in range(n):
		k += a[j]
		p += 1
		if k >= m:
			break
	print(p)


n = int(input())
m = int(input())
sizes = []
for i in range(n):
	size = int(input())
	l = -1
	r = len(sizes)
	k = (l + r) // 2
	while l + 1 < r:
		k = (l + r) // 2
		if sizes[k] > size:
			r = k
		else:
			l = k
	sizes.insert(r, size)
q = 0
i = n - 1
while m > 0:
	m -= sizes[i]
	i -= 1
	q += 1
print(q)


n = int(input())
m = int(input())
ns = [int(input()) for x in range(n)]
ns.sort(reverse=True)
resp = 0
sum_usb = 0
parcial = 0
for i in ns:
	if resp == 0 or sum_usb < m:
		sum_usb += i
		parcial += 1
	if i == m:
		resp = 1
	elif sum_usb >= m and resp == 0:
		resp = parcial
print(resp)


num_usb_drives = int(input())
size_of_file = int(input())
size_of_drives = []
for i in range(num_usb_drives):
	size_of_drives.append(int(input()))
size_of_drives.sort(reverse=True)
total_cap = 0
num_drives_reqd = 0
inx = 0
while total_cap < size_of_file:
	total_cap += size_of_drives[inx]
	inx += 1
	num_drives_reqd += 1
print(num_drives_reqd)


n = int(input())
m = int(input())
l = [int(input()) for _ in range(n)]
l.sort()
now = 0
cnt = 0
for i in l[::-1]:
	if now < m:
		now += i
		cnt += 1
print(cnt)


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
a.sort(reverse=True)
k = 0
z = 0
while z < m:
	z += a[k]
	k += 1
print(k)


import sys
n = int(input())
m = int(input())
a = []
for a00 in range(n):
	a.append(int(input()))
a.sort()
sum = 0
count = 0
for i in range(n - 1, -1, -1):
	sum += a[i]
	count += 1
	if sum >= m:
		print(count)
		sys.exit(0)


import bisect
card_q = int(input())
file_size = int(input())
storage = []
for _ in range(1, card_q + 1):
	bisect.insort(storage, int(input()))
acc = 0
for (q, card) in enumerate(storage[::-1], 1):
	acc += card
	if acc >= file_size:
		print(q)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	t = int(input())
	a.append(t)
a.sort()
while m > 0:
	m -= a.pop()
print(n - len(a))


x = int(input())
y = int(input())
p = [int(input()) for i in range(x)]
p.sort()
p.reverse()
s = 1
l = 0
for i in p:
	l += i
	if l < y:
		s += 1
	else:
		break
print(s)


(n, m) = (int(input()), int(input()))
(x, q) = ([], 0)
for _ in range(n):
	_ = int(input())
	x.append(_)
x = sorted(x)[::-1]
for i in x:
	if m > 0:
		m -= i
		q += 1
	else:
		break
print(q)


a = int(input())
s = int(input())
arr = []
for _ in range(a):
	arr.append(int(input()))
arr = sorted(arr, reverse=True)
c = 0
i = 0
for b in arr:
	c += b
	i += 1
	if c >= s:
		break
print(i)


n = int(input())
size = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
arr.sort()
arr.reverse()
count = 0
while size > 0:
	if size > arr[0]:
		size -= arr[0]
		count += 1
		arr.pop(0)
	else:
		size = 0
		count += 1
		arr.pop(0)
print(count)


n = int(input())
list_size = []
for i in range(n + 1):
	if i == 0:
		file_size = int(input())
	else:
		size = int(input())
		list_size.append(size)
list_size.sort(reverse=True)
for i in range(n):
	file_size = file_size - list_size[i]
	if file_size <= 0:
		print('{}'.format(i + 1))
		break


(n, k) = (int(input()), int(input()))
p = sorted([int(input()) for case in ' ' * n], reverse=True)
c = 0

def j(a):
	global k, c
	k = k - a
	c += 1
	if k <= 0:
		print(c)
		exit()
[j(p[i]) for i in range(n)]


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
t = n - 1
sum = 0
while sum < m:
	sum += l[t]
	t -= 1
print(n - t - 1)


n = int(input())
m = int(input())
a = sorted([int(input()) for _ in range(n)], reverse=True)
sum = 0
for i in range(n):
	sum += a[i]
	if sum >= m:
		break
print(i + 1)


import sys

def solve(file_size, drives_sizes):
	drives_sizes.sort()
	total_size = 0
	total_drives = 0
	while total_size < file_size:
		total_drives += 1
		total_size += drives_sizes.pop()
	return total_drives
assert solve(5, [2, 1, 3]) == 2
assert solve(6, [2, 3, 2]) == 3
assert solve(5, [5, 10]) == 1
nb_drives = int(input().strip())
file_size = int(input().strip())
drives_sizes = []
for _n in range(nb_drives):
	drives_sizes.append(int(input().strip()))
print(solve(file_size, drives_sizes))


n = int(input())
m = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
a.sort(reverse=True)
cnt = 0
for el in a:
	m -= el
	cnt += 1
	if m <= 0:
		break
print(cnt)


n = int(input())
m = int(input())
A = [int(input()) for i in range(n)]
A.sort(reverse=True)
c = 0
for (i, a) in enumerate(A):
	c += a
	if c >= m:
		print(i + 1)
		exit()


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
a.reverse()
r = 0
t = 0
while t < m:
	t += a[r]
	r += 1
print(r)


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
k = 0
r = 0
i = n - 1
while i >= 0:
	k += l[i]
	r += 1
	if k >= m:
		break
	i -= 1
print(r)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
a.sort(reverse=True)
c = 0
for i in a:
	if m > 0:
		m -= i
		c += 1
	else:
		break
print(c)


n = int(input())
l = int(input())
b = []
s = 0
c = []
while n > 0:
	a = int(input())
	b.append(a)
	n = n - 1
b.sort(reverse=True)
for i in range(len(b)):
	s = s + b[i]
	if s >= l:
		c.append(i + 1)
print(min(c))


try:
	while True:
		n = int(input())
		m = int(input())
		a = [0] * n
		for i in range(n):
			a[i] = int(input())
		a.sort(reverse=True)
		for i in range(n):
			m -= a[i]
			if m <= 0:
				break
		print(i + 1)
except EOFError:
	pass


num_drives = int(input())
filesize = int(input())
mylist = []
for i in range(num_drives):
	mylist.append(int(input()))
mylist.sort(reverse=True)
sum = 0
num = 0
for i in mylist:
	num += 1
	sum += i
	if sum >= filesize:
		print(num)
		break


def num_drives(num_flash, file_size, drive_sizes):
	x = sorted(drive_sizes)[::-1]
	amount_used = 0
	count = 0
	while amount_used < file_size:
		amount_used += x[count]
		count += 1
	return count
num_flash = int(input())
file_size = int(input())
drive_sizes = [int(input()) for _ in range(num_flash)]
print(num_drives(num_flash, file_size, drive_sizes))


n = int(input())
size = int(input())
cards = sorted((int(input()) for _ in range(n)))[::-1]
for (i, v) in enumerate(cards):
	size -= v
	if size <= 0:
		break
print(i + 1)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
sum = [0]
for i in range(0, n):
	sum.append(sum[i] + a[i])
for i in range(1, n + 1):
	if sum[i] >= m:
		print(i)
		exit()
	1


n = int(input())
m = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
arr.sort()
arr2 = []
while sum(arr2) < m:
	arr2.append(arr.pop())
print(len(arr2))


I = lambda : int(input())
n = I()
m = I()
a = sorted((I() for _ in '0' * n))
while sum(a[1:]) >= m:
	a = a[1:]
print(len(a))


n = int(input())
m = int(input())
usb = []
for _ in range(n):
	tmp = int(input())
	usb.append(tmp)
usb.sort(reverse=True)
ans = 0
tot = 0
for i in usb:
	if tot >= m:
		break
	else:
		tot += i
		ans += 1
print(ans)


n = int(input())
m = int(input())
p = []
for i in range(n):
	k = int(input())
	p.append(k)
p.sort()
col = 0
pos = n - 1
while m > 0:
	m -= p[pos]
	pos -= 1
	col += 1
print(col)


(n, m, list) = (int(input()), int(input()), [])
for i in range(n):
	list.append(int(input()))
list.sort(reverse=True)
i = 0
while m > 0 and i < n:
	m -= list[i]
	i += 1
print(i)


numberDrives = int(input())
sizeFile = int(input())
sizes = []
for i in range(numberDrives):
	sizes.append(int(input()))
sizes.sort()
minDrives = 0
sizeFileRemaining = sizeFile
while sizeFileRemaining > 0:
	minDrives += 1
	sizeFileRemaining -= sizes.pop()
print(minDrives)


n = int(input())
m = int(input())
L = []
for i in range(n):
	L.append(int(input()))
L.sort()
ans = 0
while m > 0:
	ans += 1
	m -= L.pop()
print(ans)


n = int(input())
m = int(input())
l = []
for _ in range(n):
	n1 = int(input())
	l.append(n1)
l.sort(reverse=True)
su = 0
p = 0
for i in l:
	su += i
	p += 1
	if su >= m:
		print(p)
		break


l = []
r = 0
o = []
n = int(input())
m = int(input())
for i in range(n):
	l += [int(input())]
while r < m:
	r += max(l)
	o += [max(l)]
	l.remove(max(l))
print(len(o))


def flash_karty(lst, m):
	(count, summa) = (0, 0)
	for i in range(len(lst)):
		summa += sorted(lst, reverse=True)[i]
		count += 1
		if summa >= m:
			break
	return count
N = int(input())
M = int(input())
a = list()
for i in range(N):
	x = int(input())
	a.append(x)
print(flash_karty(a, M))


drives = int(input())
size = int(input())
sizes = []
for i in range(1, drives + 1):
	sz = int(input())
	sizes.append(sz)
sizes.sort(reverse=True)
tot_drives = 1
for s in sizes:
	size = size - s
	if size <= 0:
		continue
	else:
		tot_drives = tot_drives + 1
print(tot_drives)


n = int(input())
m = int(input())
k = []
for i in range(n):
	h = int(input())
	k.append(h)
k.sort()
p = 0
s = 0
for i in range(n - 1, -1, -1):
	if s < m:
		s += k[i]
		p += 1
print(p)


n = int(input())
m = int(input())
(lst, c) = ([], 0)
for i in range(n):
	lst.append(int(input()))
lst.sort(reverse=True)
for nu in lst:
	if m - nu <= 0:
		c += 1
		break
	else:
		m -= nu
		c += 1
print(c)


import sys
from collections import Counter
sizes_of_drives = []
no_of_drives = int(input())
size_of_file = int(input())
a = 0
while a < no_of_drives:
	a = a + 1
	sizes_of_drives += [int(input())]
n = no_of_drives
m = size_of_file
A = sizes_of_drives
A = sorted(A, reverse=True)
i = 0
while m > 0:
	m = m - A[i]
	i += 1
print(i)


n = int(input())
m = int(input())
l = []
count = 0
j = 1
for i in range(n):
	x = int(input())
	l.append(x)
l = sorted(l, reverse=True)
for i in l:
	count += i
	if count < m:
		j += 1
print(j)


n = int(input())
m = int(input())
a = sorted([int(input()) for i in range(n)], reverse=True)
k = 0
while m > sum(a[:k]):
	k += 1
print(k)


n = int(input())
m = int(input())
a = [0 for x in range(n)]
for i in range(n):
	a[i] = int(input())
b = sorted(a, reverse=True)
s = 0
for i in range(n):
	s = s + b[i]
	if s >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
li = []
ans = 0
count = 0
for _ in range(n):
	size = int(input())
	li.append(size)
li = sorted(li, reverse=True)
for i in li:
	ans += i
	count += 1
	if ans >= m:
		break
print(count)


AantalUSB = int(input())
FileGrootte = int(input())
GrootteUSB = []
SomUSB = 0
x = 0
for i in range(0, AantalUSB):
	GrootteUSB.append(int(input()))
GrootteUSB = sorted(GrootteUSB)
for j in range(AantalUSB - 1, -1, -1):
	if SomUSB < FileGrootte:
		SomUSB += GrootteUSB[j]
		x += 1
	else:
		break
print(x)


n = int(input())
m = int(input())
l = sorted((int(input()) for i in range(n)))[::-1]
for i in range(n + 1):
	if m <= 0:
		print(i)
		break
	m -= l[i]


num_of_usb = int(input())
size_of_file = int(input())
flashdrives = [int(input()) for i in range(num_of_usb)]
ordered = sorted(flashdrives)
ordered.reverse()
storage = 0
idx = 0
while storage < size_of_file:
	storage += ordered[idx]
	idx += 1
print(idx)


n = int(input())
m = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
l = list(reversed(l))
counter = 0
idx = 0
while counter < m:
	counter += l[idx]
	idx += 1
print(idx)


n = int(input())
m = int(input())
c = 0
lis_input = []
for i in range(n):
	lis_input.append(int(input()))
lis_output = sorted(lis_input)
for i in range(n, 0, -1):
	if 0 < m - int(lis_output[i - 1]):
		c += 1
		m = m - int(lis_output[i - 1])
	elif m - int(lis_output[i - 1]) <= 0:
		c += 1
		break
print(c)


n = input()
n = int(n)
m = input()
m = int(m)
a = []
counter = 0
for i in range(n):
	x = input()
	x = int(x)
	a.append(x)
while m > 0:
	m = m - max(a)
	a[a.index(max(a))] = 0
	counter += 1
print(counter)


def solve():
	n = int(input())
	m = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	a.sort()
	count = 0
	i = len(a) - 1
	while m > 0:
		count += 1
		m -= a[i]
		i -= 1
	print(count)
solve()


(n, m, v) = (int(input()), int(input()), 0)
for (i, c) in enumerate(sorted((int(input()) for i in range(n)), reverse=True)):
	v += c
	if v >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
q = 0
c = 0
while m > 0:
	if m >= a[c]:
		q += 1
		m -= a[c]
		c += 1
	else:
		q += 1
		break
print(q)


import sys
n = int(input())
count = 0
file = int(input())
drives = []
for i in range(n):
	drives.append(int(input()))
for k in drives:
	if k == file or k > file:
		print('1')
		sys.exit()
drives.sort(reverse=True)
sum = 0
for l in range(0, len(drives), 1):
	sum = sum + drives[l]
	if sum >= file:
		print(l + 1)
		break


number = int(input())
size = int(input())
cards = []
cnt = 0
for i in range(number):
	cards.append(int(input()))
cards.sort()
while size > 0:
	size -= cards.pop()
	cnt += 1
print(cnt)


n = int(input())
size = int(input())
usbs = []
for i in range(n):
	m = int(input())
	usbs.append(m)
sum = 0
k = 0
for j in range(n):
	sum += max(usbs)
	usbs.remove(max(usbs))
	k += 1
	if sum >= size:
		break
print(k)


n = int(input())
m = int(input())
a = [int(input()) for i in range(n)]
a.sort(reverse=True)
s = 0
c = 0
for x in a:
	s += x
	c += 1
	if s >= m:
		break
print(c)


n = int(input())
m = int(input())
ns = []
for i in range(n):
	ns.append(int(input()))
ns = sorted(ns, reverse=True)
ans = 0
sum_ = 0
parcial = 0
for i in ns:
	if ans == 0 or sum_ < m:
		sum_ += i
		parcial += 1
	if i == m:
		ans = 1
	elif sum_ >= m and ans == 0:
		ans = parcial
print(ans)


n = int(input())
m = int(input())
sb = []
for i in range(n):
	sb.append(int(input()))
sb.sort()
step = 0
for i in range(n - 1, -1, -1):
	m -= sb[i]
	step += 1
	if m <= 0:
		break
print(step)


n = int(input())
m = int(input())
_list = []
for i in range(n):
	_list.append(int(input()))
_list.sort(reverse=True)
cnt = 0
for i in _list:
	if m > 0:
		m -= i
	else:
		break
	cnt += 1
print(cnt)


n = int(input())
s = int(input())
l = sorted([int(input()) for _ in range(n)], reverse=True)
c = 0
while s > 0:
	s -= l[c]
	c += 1
print(c)


(n, m) = (int(input()), int(input()))
a = [int(input()) for _ in range(n)]
a.sort()
a.reverse()
ans = 0
while m > 0:
	m -= a[ans]
	ans += 1
print(ans)


n = int(input())
m = int(input())
flashed = [int(input()) for i in range(n)]
flashed.sort(reverse=True)
(counter, sumSize) = (0, 0)
for size in flashed:
	sumSize += size
	counter += 1
	if sumSize >= m:
		break
print(counter)


n = int(input())
m = int(input())
a = []
j = n - 1
for i in range(n):
	a.append(int(input()))
a.sort()
while m > 0:
	m = m - a[j]
	j = j - 1
print(n - j - 1)


import time
n = int(input())
m = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
start = time.time()
a = sorted(a, key=lambda x: -x)
ans = 0
while m > 0:
	m -= a[ans]
	ans += 1
print(ans)
finish = time.time()


n = int(input())
m = int(input())
a = list((int(input()) for i in range(n)))
a.sort()
s = 0
flag = 0
while s < m:
	if m - s >= a[-1]:
		s += a[-1]
		a.remove(a[-1])
		flag += 1
	elif m - s < a[-1]:
		flag += 1
		break
print(flag)


usb = int(input())
file = int(input())
usb_drives = []
sum = 0
for i in range(0, usb):
	usb_drives.append(int(input()))
usb_drives = list(reversed(sorted(usb_drives)))
j = 0
while sum < file:
	sum += usb_drives[j]
	j += 1
print(j)


n = int(input())
m = int(input())
mas = []
s = 0
t = 0
for i in range(n):
	mas.append(int(input()))
mas = sorted(mas, reverse=True)
for i in mas:
	if t >= m:
		break
	s += 1
	t += i
print(s)


import bisect
import itertools

def main():
	n = int(input())
	m = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	a.sort(reverse=True)
	a = [0] + list(itertools.accumulate(a))
	print(bisect.bisect_left(a, m))
main()


n = int(input())
file = int(input())
ans = []
for x in range(n):
	a = int(input())
	ans.append(a)
ans = sorted(ans)
ans = ans[::-1]
count = 0
while file > 0:
	file -= ans[count]
	count += 1
print(count)


I = lambda : int(input())
(n, m) = (I(), I())
s = sorted([I() for i in range(n)])[::-1]
for i in range(n + 1):
	if sum(s[:i]) >= m:
		print(i)
		break


n = int(input())
m = int(input())
k = []
pd = 0
ans = 0
for i in range(0, n):
	k.append(int(input()))
k = sorted(k)
k.reverse()
while m > 0:
	m -= k[pd]
	pd += 1
	ans += 1
print(ans)


n = int(input())
m = int(input())
options = [0] * n
for i in range(n):
	options[i] = int(input())
options.sort()
tot = 0
count = 0
while tot < m:
	tot += options[n - 1 - count]
	count += 1
print(count)


n = int(input())
m = int(input())
f = []
for i in range(n):
	f.append(int(input()))
f.sort(reverse=True)
s = 0
r = 0
while s < m:
	s += f[r]
	r += 1
print(r)


from random import *

def quick_sort(array):
	return quick_sort([x for x in array[1:] if x < array[0]]) + [array[0]] + quick_sort([x for x in array[1:] if x >= array[0]]) if array else []
n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a = quick_sort(a)
s = 0
i = len(a) - 1
while i >= 0:
	s += a[i]
	if s >= m:
		print(len(a) - i)
		break
	i -= 1


usb = int(input())
f_size = int(input())
usb_size = []
for i in range(0, usb):
	usb_size.append(int(input()))
usb_size.sort()
total = 0
no_of_usb = 0
for i in usb_size[::-1]:
	total += i
	no_of_usb += 1
	if total >= f_size:
		break
print(no_of_usb)


from bisect import *

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

def inp():
	return int(input())
n = inp()
m = inp()
a = []
for i in range(n):
	a.append(inp())
a.sort()
a.reverse()
for i in range(1, n):
	a[i] += a[i - 1]
print(bisect_left(a, m) + 1)


(a, b) = (int(input()), int(input()))
sizes = [int(input()) for x in range(a)]
sizes = sorted(sizes)[::-1]
u = 0
n = 0
while n < b:
	n += sizes[u]
	u += 1
print(u)


n = int(input())
m = int(input())
arr = [int(input()) for i in range(n)]
arr.sort()
N = len(arr)
i = 0
while m > 0:
	i += 1
	m -= arr[N - i]
print(i)


n = int(input())
m = int(input())
l = [0] * n
for i in range(n):
	l[i] = int(input())
l.sort(reverse=True)
ans = 0
temp = 0
for i in l:
	temp += i
	ans -= -1
	if temp >= m:
		print(ans)
		break


n = int(input())
size = int(input())
k = []
for m in range(n):
	k.append(int(input()))
k.sort()
num = 0
while size > 0:
	size = size - k.pop()
	num = num + 1
print(num)


n = int(input())
m = int(input())
a = []
k = 0
for i in range(n):
	a.append(int(input()))
while m > 0:
	mx = max(a)
	m = m - mx
	k += 1
	a.pop(a.index(mx))
print(k)


n = int(input())
m = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l.sort()
t = n - 1
sum1 = 0
while sum1 < m:
	sum1 += l[t]
	t -= 1
print(n - t - 1)


def usb(n, m, a):
	total = 0
	num = 0
	a = sorted(a, reverse=True)
	if a[0] > m:
		return 1
	i = 0
	while total < m:
		total += a[i]
		num += 1
		i += 1
	return num
n = int(input())
m = int(input())
a = []
for i in range(0, n):
	tmp = int(input())
	a.append(tmp)
print(usb(n, m, a))


n = int(input())
m = int(input())
sizes = []
for i in range(n):
	sizes.append(int(input()))
sizes = sorted(sizes, reverse=True)
value = sizes[0]
count = 1
for i in range(1, n):
	if value >= m:
		break
	value = value + sizes[i]
	count += 1
print(count)


case = int(input())
data = int(input())
x = 0
size = []
for trail in range(0, case):
	x = int(input())
	size.append(x)
size.sort(reverse=True)
total = 0
index = 0
for trail in range(0, case):
	total = total + size[index]
	index += 1
	if total >= data:
		break
print(index)


n = int(input())
val = int(input())
aux = 0
lis = []
for _ in range(n):
	lis.append(int(input()))
lis.sort(reverse=True)
for i in range(n):
	aux += lis[i]
	if aux >= val:
		print(i + 1)
		break


n = int(input())
t = int(input())
s = []
while n:
	x = int(input())
	s.append(x)
	n -= 1
s.sort()
ans = 0
while t > 0:
	t -= s[-1]
	s.pop()
	ans += 1
print(ans)


n = int(input())
s = int(input())
listl = []
sum1 = 0
count = 1
for i in range(n):
	j = int(input())
	listl.append(j)
listl.sort()
for i in range(1, n):
	sum1 += listl[-i]
	if s > sum1:
		count += 1
print(count)


n = int(input())
d = []
c = 0
for i in range(n + 1):
	s = int(input())
	d.append(s)
r = d.pop(0)
d.sort(reverse=True)
while r > 0:
	r -= d[c]
	c += 1
print(c)


def gasienica(A, s):
	n = len(A)
	(front, total) = (0, 0)
	ile = 0
	for back in range(n):
		while front < n and total < s:
			total += A[front]
			front += 1
			ile += 1
		if total >= s:
			return ile
		total -= A[back]
		ile -= 1
	return n
n = int(input())
m = int(input())
tab = [0] * n
for i in range(n):
	tab[i] = int(input())
tab.sort(reverse=True)
print(gasienica(tab, m))


n = int(input())
m = int(input())
line = list()
for i in range(n):
	line.append(int(input()))
line.sort(reverse=True)
temp_sum = 0
for i in range(n):
	temp_sum += line[i]
	if not temp_sum < m:
		print(i + 1)
		break


n = int(input())
s = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
l.sort()
count = 0
w = []
for i in range(n - 1, -1, -1):
	w.append(l[i])
	count += 1
	if sum(w) >= s:
		break
print(count)


def function():
	totalDrives = int(input())
	fileSize = int(input())
	drives = []
	for element in range(totalDrives):
		temp = int(input())
		drives.append(temp)
	drives.sort()
	currentSize = 0
	driveCount = 0
	while currentSize < fileSize:
		currentSize += drives.pop()
		driveCount += 1
	return driveCount
print(function())


n = int(input())
m = int(input())
usba = []
for i in range(n):
	s = int(input())
	usba.append(s)
usba.sort(reverse=True)
usbsum = 0
usbcount = 0
while usbsum < m:
	usbsum += usba[usbcount]
	usbcount += 1
print(usbcount)


n = int(input())
s = int(input())
y = []
s_sum = 0
for i in range(n):
	y.append(int(input()))
y.sort()
y.reverse()
for i in range(n):
	s_sum += y[i]
	if s_sum >= s:
		print(i + 1)
		break


n = int(input())
fsize = int(input())
p = []
(sum, counter) = (0, 0)
for i in range(0, n):
	p.append(int(input()))
p.sort()
for i in range(n - 1, -1, -1):
	sum += p[i]
	counter += 1
	if sum >= fsize:
		print(counter)
		exit()


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
if a[-1] >= m:
	print(1)
else:
	file = 0
	y = n - 1
	while m > 0:
		m = m - a[y]
		y -= 1
		file += 1
	print(file)


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]
a.sort(key=lambda x: -x)
i = 0
while m > 0:
	m -= a[i]
	i += 1
print(i)


drives = int(input())
size = int(input())
drive = []
for i in range(0, drives):
	drive.append(int(input()))
drive.sort(reverse=True)
minSize = 0
count = 0
for sizes in drive:
	count = count + 1
	minSize = minSize + sizes
	if minSize >= size:
		print(count)
		break


n = int(input())
m = int(input())
l = [int(input()) for i in range(n)]
l.sort(reverse=True)
tot = 0
c = 0
i = 0
while m > 0:
	m -= l[i]
	i += 1
	c += 1
print(c)


n = int(input())
size = int(input())
ary = [int(input()) for _ in range(n)]
ary.sort()
ary.reverse()
count = 0
while size > 0:
	count += 1
	size -= ary[count - 1]
print(count)


n = int(input())
m = int(input())
array = list()
min_drives = 0
for i in range(n):
	array.append(int(input()))
array = sorted(array)
array = array[::-1]
for element in array:
	m = m - element
	if m > 0:
		min_drives += 1
	if m <= 0:
		min_drives += 1
		break
print(min_drives)


n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
count = 0
sum = 0
arr.sort()
arr.reverse()
for i in arr:
	if sum >= m:
		break
	else:
		sum = sum + i
		count = count + 1
print(count)


N = int(input())
M = int(input())
A = [int(input()) for _ in range(N)]
A.sort(reverse=True)
res = 0
cap = 0
for i in range(N):
	cap += A[i]
	res += 1
	if cap >= M:
		print(res)
		break


n = int(input())
size = int(input())
drives = [i for i in range(n)]
while n > 0:
	drives[n - 1] = int(input())
	n -= 1
drives.sort(reverse=True)
rem = 0
i = 0
for d in drives:
	if rem >= size:
		break
	else:
		rem += d
	i += 1
print(i)


flashNum = int(input())
fileSize = int(input())
sizeList = []
for i in range(0, flashNum):
	sizeList.insert(i, int(input()))
sizeList.sort()
counter = 0
j = len(sizeList) - 1
while True:
	if fileSize == 0 or fileSize < 0:
		break
	fileSize -= sizeList[j]
	j -= 1
	counter += 1
print(counter)


n = int(input())
dem = 0
a = []

def swap(a, b):
	return (b, a)
m = int(input())
for i in range(0, n):
	a.append(int(input()))
for i in range(0, n - 1):
	for j in range(i + 1, n):
		if a[j] > a[i]:
			(a[i], a[j]) = swap(a[i], a[j])
dex = 0
while m > 0:
	m -= a[dex]
	dem += 1
	dex += 1
print(dem)


n = int(input())
m = int(input())
yo = []
for i in range(n):
	x = int(input())
	yo.append(x)
yo.sort(reverse=True)
to = 0
for i in range(n):
	to += yo[i]
	if to >= m:
		break
print(i + 1)


n = int(input())
m = int(input())
res = []
for i in range(n):
	res.append(int(input()))
res.sort(reverse=True)
count = 0
byte = 0
for i in res:
	byte += i
	count += 1
	if byte >= m:
		break
print(count)


from sys import stdin, stdout
number_of_drives = map(int, stdin.readline().rstrip().split()).__next__()
file_size = map(int, stdin.readline().rstrip().split()).__next__()
drives_capacity = []
for drive in range(number_of_drives):
	drives_capacity.append(map(int, stdin.readline().rstrip().split()).__next__())
drives_capacity.sort(reverse=True)
needed_drives_counter = 0
for drive_capacity in drives_capacity:
	file_size -= drive_capacity
	needed_drives_counter += 1
	if file_size <= 0:
		break
stdout.write(str(needed_drives_counter))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
usb = []
n = get_int()
m = get_int()
for _ in range(n):
	usb.append(get_int())
usb = reversed(sorted(usb))
s = 0
count = 0
for ele in usb:
	if s >= m:
		break
	else:
		s += ele
		count += 1
print(count)


n = int(input())
m = int(input())
count = 0
s = 0
c = []
for i in range(n):
	a = int(input())
	c.append(a)
c.sort(reverse=True)
if sum(c) < m:
	print('0')
for i in range(len(c)):
	s = s + c[i]
	if s >= m:
		break
	if s < m:
		count += 1
print(count + 1)


n = int(input())
m = int(input())
p = [None] * n
for i in range(n):
	p[i] = int(input())
p.sort(reverse=True)
s = 0
while m > 0:
	m -= p[s]
	s += 1
print(s)


n = int(input())
m = int(input())
arr = [0] * n
for x in range(n):
	arr[x] = int(input())
arr.sort()
arr = arr[::-1]
su = 0
for x in range(n):
	su = su + arr[x]
	if su >= m:
		break
print(x + 1)


n = int(input())
size = int(input())
usbs = []
for i in range(n):
	m = int(input())
	usbs.append(m)
usbs.sort(reverse=True)
sum = 0
k = 0
for j in range(n):
	sum += usbs[j]
	k += 1
	if sum >= size:
		break
print(k)


n = int(input())
m = int(input())
fl = []
for i in range(n):
	fl.append(int(input()))
fl.sort()
fl = list(reversed(fl))
summ = 0
coun = 0
while summ < m:
	summ += fl[coun]
	coun += 1
print(coun)


c = 0
x = 0
a = []
n = int(input())
m = int(input())
for i in range(n):
	a.append(int(input()))
a = sorted(a)
a = a[::-1]
for i in range(n):
	x += a[i]
	c += 1
	if x >= m:
		break
print(c)


n = int(input())
l = []
for z in range(n + 1):
	l.append(int(input()))
m = l[0]
l.remove(l[0])
l.sort()
l.reverse()
s = 0
i = 0
c = 0
while s < m:
	s += l[i]
	c += 1
	i += 1
print(c)


import unittest
import sys

class First:

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else sys.stdin.readline().rstrip()
		[self.n] = map(int, uinput().split())
		[self.m] = map(int, uinput().split())
		self.nums = [int(uinput()) for i in range(self.n)]
		self.numss = list(reversed(sorted(self.nums)))

	def calculate(self):
		result = 0
		sum = 0
		for i in range(self.n):
			sum += self.numss[i]
			result += 1
			if sum >= self.m:
				break
		return str(result)

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '3\n5\n2\n1\n3'
		d = First(test)
		self.assertEqual(d.n, 3)
		self.assertEqual(d.m, 5)
		self.assertEqual(d.nums, [2, 1, 3])
		self.assertEqual(d.numss, [3, 2, 1])
		self.assertEqual(First(test).calculate(), '2')
		test = '3\n6\n2\n3\n2'
		self.assertEqual(First(test).calculate(), '3')
		test = '2\n5\n5\n10'
		self.assertEqual(First(test).calculate(), '1')
		test = ''

	def time_limit_test(self, nmax):
		import random
		import timeit
		test = str(nmax) + ' ' + str(nmax) + '\n'
		numnums = [str(i) + ' ' + str(i + 1) for i in range(nmax)]
		test += '\n'.join(numnums) + '\n'
		nums = [random.randint(1, 10000) for i in range(nmax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = First(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(First().calculate())


n = int(input())
m = int(input())
size = list()
for i in range(n):
	t = int(input())
	size.append(t)
size.sort(reverse=True)
i = 0
while i < len(size):
	m -= size[i]
	i += 1
	if m <= 0:
		break
print(i)


n = int(input())
m = int(input())
usbs = []
for i in range(n):
	usbs += [int(input())]
usbs.sort(reverse=True)
curSum = 0
for i in range(len(usbs)):
	curSum += usbs[i]
	if curSum >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
l.sort(reverse=True)
c = 0
s = 0
for i in l:
	s += i
	c += 1
	if s >= m:
		break
	else:
		continue
print(c)


def BubbleSort(alist):
	for i in range(len(alist) - 1, 0, -1):
		flag = 0
		for k in range(i):
			if alist[k] > alist[k + 1]:
				(alist[k], alist[k + 1]) = (alist[k + 1], alist[k])
				flag = 1
		if flag == 0:
			break
	return alist
n = int(input())
m = int(input())
arr = []
res = 0
cnt = 1
for i in range(n):
	x = int(input())
	arr.append(x)
arr = BubbleSort(arr)
if m in arr:
	print(1)
else:
	for i in range(n - 1, -1, -1):
		res += arr[i]
		if res >= m:
			print(cnt)
			exit(0)
		cnt += 1


n = int(input())
m = int(input())
p = []
count = 0
for i in range(n):
	x = int(input())
	p.append(x)
	p.sort()
for j in range(n - 1, -1, -1):
	if m > 0:
		count += 1
		a = m - p[j]
		m = a
print(count)


a = int(input())
b = int(input())
S = []
for i in range(a):
	S.append(int(input()))
S = sorted(S, reverse=-1)
k = 0
for i in range(a):
	k += S[i]
	if k >= b:
		print(i + 1)
		break


rep = int(input())
num = int(input())
lista = []
for i in range(rep):
	lista.append(int(input()))
lista.sort()
soma = 0
for i in range(1, rep + 1):
	soma += lista[-i]
	if soma >= num:
		print(i)
		break


a = int(input())
b = int(input())
x = []
cnt = 0
for i in range(a):
	x.append(int(input()))
x.sort()
while b > 0:
	b = b - x.pop()
	cnt += 1
print(cnt)


n = int(input())
m = int(input())
ip = []
for i in range(n):
	ip.append(int(input()))
ip = sorted(ip)
i = 1
count = 0
while m > 0:
	m -= ip[-i]
	count += 1
	i += 1
print(count)


N = int(input())
M = int(input())
L = [int(input()) for _ in range(N)]
L.sort(reverse=True)
i = 0
now = 0
while True:
	now += L[i]
	i += 1
	if now >= M:
		print(i)
		exit()


n = int(input())
m = int(input())
size = []
for i in range(n):
	a = int(input())
	size.append(a)
size.sort(reverse=True)
sum = 0
count = 0
for i in size:
	sum += i
	count += 1
	if sum >= m:
		break
print(count)


n = int(input())
m = int(input())
ns = []
for i in range(0, n):
	ns.append(int(input()))
result = 0
remainderBytes = m
for si in sorted(ns, reverse=True):
	remainderBytes -= si
	result += 1
	if remainderBytes <= 0:
		break
print(result)


import sys
import math
import bisect

def main():
	n = int(input())
	m = int(input())
	A = []
	for i in range(n):
		A.append(int(input()))
	A.sort(reverse=True)
	for i in range(1, n):
		A[i] += A[i - 1]
	p = bisect.bisect_left(A, m)
	print(p + 1)
main()


num_lines = int(input())
mem_store = int(input())
usb_list = list()
for usb in range(num_lines):
	usb = int(input())
	usb_list.append(usb)
l = sorted(usb_list, reverse=True)
for ele in range(num_lines):
	mem_store = mem_store - l[ele]
	if mem_store <= 0:
		print(ele + 1)
		break


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
b = sorted(a)[::-1]
count = 0
somma = 0
i = 0
while m > somma:
	somma += b[i]
	count += 1
	i += 1
print(count)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort()
summ = 0
num = 0
for f in reversed(a):
	if summ >= m:
		break
	summ += f
	num += 1
print(num)


n = int(input())
k = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort()
l = l[::-1]
count = 0
s = 0
for i in range(n):
	if s < k:
		s += l[i]
		count += 1
print(count)


n = int(input())
m = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
a.sort()
a.reverse()
i = 0
s = 0
while s < m:
	s = s + a[i]
	i += 1
print(i)


query = int(input())
file = int(input())
l = []
for _ in range(query):
	l.append(int(input()))
l.sort(reverse=True)
i = count = 0
while file > 0:
	file -= l[i]
	count += 1
	i += 1
print(count)


n = int(input())
m = int(input())
res = 0
flash = []
sum = 0
for i in range(n):
	flash.append(int(input()))
flash.sort()
for j in range(len(flash) - 1, -1, -1):
	sum += int(flash[j])
	res += 1
	if sum >= m:
		break
print(res)


from __future__ import print_function
import sys
n = int(input())
m = int(input())
x = []
for i in range(0, n):
	x.append(int(input()))
y = sorted(x, key=lambda x: -x)
idx = 0
count = 0
while m > 0:
	m = m - y[idx]
	idx = idx + 1
	count = count + 1
print(count)


import sys
A = [int(x) for x in sys.stdin.read().split()]
aantalflashdrives = A[0]
grootte = A[1]
del A[0]
del A[0]
count = 0
while grootte > 0:
	count += 1
	grootte -= max(A)
	A.remove(max(A))
print(count)


import math
from sys import stdin
input = stdin.readline
lines = int(input())
size = int(input())
usb = []
for i in range(lines):
	usb.append(int(input()))
usb.sort(reverse=True)
num = 0
total = 0
for i in range(lines):
	if total < size:
		total += usb[i]
		num += 1
print(num)


(n, m, a, k) = (int(input()), int(input()), [], 0)
while n > 0:
	n -= 1
	a.append(int(input()))
a.sort()
for i in a[::-1]:
	m -= i
	k += 1
	if m <= 0:
		break
print(k)


n = int(input())
m = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
a = sorted(a, reverse=True)
solution = 0
for i in a:
	if m > 0:
		m -= i
		solution += 1
	else:
		break
print(solution)


nom = int(input())
size = int(input())
usb = []
sum = 0
x = True
for i in range(nom):
	usb.append(int(input()))
usb.sort(reverse=True)
for i in usb:
	if size >= i and x == True:
		size -= i
		sum += 1
	else:
		x = False
if size > 0:
	sum += 1
print(sum)


n = int(input())
file_size = int(input())
usb_sizes = [int(input()) for s in range(n)]
min_usb = n + 1
while sum(usb_sizes) >= file_size:
	min_usb = min_usb - 1
	usb_sizes.remove(min(usb_sizes))
print(min_usb)


t = int(input())
m = int(input())
l = []
for i in range(t):
	x = int(input())
	l.append(x)
l.sort(reverse=True)
i = 0
sum = 0
j = 0
while sum < m:
	sum = sum + l[j]
	j += 1
	i += 1
print(i)


def min_number_usbs(A, m):
	A = sorted(A, reverse=True)
	i = 0
	while m > 0:
		m = m - A[i]
		i += 1
	return i
n = int(input())
m = int(input())
A = list()
while n > 0:
	A.append(int(input()))
	n -= 1
print(min_number_usbs(A, m))


n = int(input())
m = int(input())
lst = []
for i in range(n):
	lst.append(int(input()))
lst = sorted(lst)[::-1]
s = 0
cnt = 0
while s < m:
	s += lst[cnt]
	cnt += 1
print(cnt)


n = int(input())
S = int(input())
Val = []
for _ in range(n):
	Val.append(int(input()))
Val.sort(reverse=True)
(N, Sum) = (0, 0)
for i in range(n):
	Sum += Val[i]
	N += 1
	if Sum >= S:
		break
print(N)


n1 = input()
n = int(n1)
m1 = input()
m = int(m1)
f = []
for i in range(n):
	a1 = input()
	a = int(a1)
	f += [a]
f.sort()
d = len(f)
while m > 0:
	m = m - f[-1]
	f.pop()
print(d - len(f))


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def solve():
	n = int(input())
	m = int(input())
	a = [0] * n
	for i in range(n):
		a[i] = int(input())
	a.sort(reverse=True)
	res = 0
	for i in range(len(a)):
		m -= a[i]
		res += 1
		if m <= 0:
			break
	cout << res << endl

def main():
	solve()
main()


n = int(input())
f = int(input())
m = []
for _ in range(n):
	m.append(int(input()))
m.sort(reverse=True)
c = 0
s = 0
for i in m:
	s += i
	c += 1
	if s >= f:
		break
print(c)


n = int(input())
m = int(input())
A = list(map(int, [input() for i in range(n)]))
A.sort(reverse=True)
ans = 0
sum = 0
for i in range(n):
	ans += 1
	sum += A[i]
	if sum >= m:
		break
print(ans)


n = int(input())
m = int(input())
x = []
for i in range(n):
	x.append(int(input()))
x.sort(reverse=True)
count = 0
for i in range(len(x)):
	count += 1
	m -= x[i]
	if m <= 0:
		break
print(count)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
n = mint()
m = mint()
a = []
for i in range(n):
	a.append(mint())
a.sort(reverse=True)
c = 0
for i in a:
	if m == 0:
		break
	m = max(m - i, 0)
	c += 1
print(c)


n = int(input())
m = int(input())
a = []
summa = 0
status = False
ll = -1
ll2 = n - 1
count = 1
for i in range(n):
	s = int(input())
	a.append(s)
a = sorted(a, reverse=True)
if sum(a) <= m:
	print(n)
elif min(a) >= m:
	print(1)
else:
	while True:
		ll += 1
		if ll == ll2:
			break
		if summa > m:
			summa += a[ll]
			status = False
			print(count - 1)
			break
		else:
			status = True
			summa += a[ll]
			if summa == m:
				break
			count += 1
	if status:
		print(count)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
used = 0
for num in a:
	m -= num
	used += 1
	if m <= 0:
		break
print(used)


v = int(input())
m = int(input())
lista = []
for i in range(v):
	a = int(input())
	lista.append(a)
lista = sorted(lista, reverse=True)
c = 0
f = 0
for x in lista:
	c += x
	if c >= m:
		f += 1
		break
	f += 1
print(f)


z = input
n = int(z())
x = int(z())
c = 0
l = []
s = 0
for i in range(n):
	p = int(z())
	l.append(p)
l = sorted(l)
for i in l[::-1]:
	s += i
	c += 1
	if s >= x:
		print(c)
		break


n = int(input())
c = int(input())
d = []
k = 0
for i in range(n):
	s = int(input())
	d.append(s)
d.sort(reverse=True)
for i in d:
	c = c - i
	k = k + 1
	if c <= 0:
		break
print(k)


n = int(input())
file_size = int(input())
usb_size = []
for i in range(n):
	usb_size.append(int(input()))
usb_size.sort(reverse=True)
for_now = 0
for i in range(n):
	for_now += usb_size[i]
	if for_now >= file_size:
		print(i + 1)
		break


a = int(input())
m = int(input())
b = []
for i in range(a):
	c = int(input())
	b.append(c)
b.sort()
b.reverse()
d = 0
e = 0
for i in range(a):
	d += b[i]
	e += 1
	if d >= m:
		print(e)
		break


n = int(input())
m = int(input())
ls = []
for _ in range(n):
	ls.append(int(input()))
ls_sort = sorted(ls)[::-1]
s = 0
for i in range(len(ls_sort)):
	s += ls_sort[i]
	if s >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
x = []
v = []
count = 0
for i in range(n):
	f = int(input())
	x.append(f)
x.sort()
v = x[::-1]
for i in range(n):
	if m > 0:
		m -= v[i]
		count += 1
	else:
		break
print(count)


def main():
	n = int(input())
	m = int(input())
	data = []
	for i in range(n):
		data.append(int(input()))
	data.sort(reverse=True)
	s = 0
	for (i, v) in enumerate(data):
		s = s + v
		if s >= m:
			print(i + 1)
			return
main()


n = int(input())
m = int(input())
l = []
for i in range(n):
	t = int(input())
	l.append(t)
l = sorted(l, reverse=True)
num = 0
for i in l:
	if m <= 0:
		break
	m -= i
	num += 1
print(num)


n = int(input())
m = int(input())
usb = []
for _ in range(n):
	usb.append(int(input()))
usb.sort(reverse=True)
c = 0
for (i, item) in enumerate(usb):
	c += item
	if c >= m:
		print(i + 1)
		break


n = int(input())
s = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
a.sort(reverse=True)
for i in range(1, n):
	a[i] += a[i - 1]
for i in range(n):
	if a[i] >= s:
		print(i + 1)
		exit(0)


n = int(input())
m = int(input())
list_usbs = []
for i in range(n):
	list_usbs.append(int(input()))
list_usbs.sort(reverse=True)
ss = 0
c = 0
for i in range(n):
	if ss < m:
		ss = ss + int(list_usbs[c])
		c = c + 1
print(c)


n = input()
n = int(n)
m = input()
m = int(m)
caps = []
for i in range(int(n)):
	cap = input()
	cap = int(cap)
	caps.append(cap)
caps.sort(reverse=True)
count = 0
value = 0
for cap in caps:
	count += 1
	value = value + cap
	if value >= m:
		break
print(count)


n = int(input())
m = int(input())
s = []
for i in range(n):
	s.append(int(input()))
s.sort(reverse=True)
for (i, j) in enumerate(s):
	m -= j
	if m <= 0:
		print(i + 1)
		exit(0)


n = int(input())
m = int(input())
a = []
summa = 0
count = 0
for i in range(n):
	s = int(input())
	a.append(s)
a = sorted(a, reverse=True)
for j in range(n):
	summa += a[j]
	count += 1
	if summa >= m:
		break
print(count)


n = int(input())
m = int(input())
flash = []
for i in range(n):
	flash.append(int(input()))
flash.sort(key=lambda x: -x)
prefix = 0
for i in range(n):
	prefix += flash[i]
	if m <= prefix:
		print(i + 1)
		break
else:
	print('?')


m = int(input())
s = int(input())
lis = []
for i in range(m):
	lis.append(int(input()))
lis.sort(reverse=True)
mx = 0
i = 0
while s > mx:
	mx += lis[i]
	i += 1
print(i)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	m = I()
	a = sorted([I() for _ in range(n)])
	r = 0
	for c in a[::-1]:
		m -= c
		r += 1
		if m <= 0:
			break
	return r
print(main())


def number_usb(usb, size):
	size_b = 0
	count = 0
	while size_b < size:
		size_b += max(usb)
		usb.pop(usb.index(max(usb)))
		count += 1
	return count
usb = []
m = int(input())
size = int(input())
for r in range(m):
	usb.append(int(input()))
print(number_usb(usb, size))


diskN = int(input())
memory = int(input())
memoryList = [int(input()) for k in range(0, diskN)]
memoryList.sort()
count = 0
sumM = 0
while sumM < memory:
	sumM += memoryList.pop()
	count += 1
print(count)


n = int(input())
a = int(input())
sizes = [int(input()) for s_in in range(n)]
sorted_sizes = sorted(sizes)
sorted_sizes.reverse()
i = 0
sum_s = 0
for s in sorted_sizes:
	sum_s += s
	i += 1
	if sum_s >= a:
		break
print(i)


n = int(input())
m = int(input())
a = []
sum1 = 0
for _ in range(n):
	a.append(int(input()))
a.sort()
a.reverse()
for i in range(n):
	sum1 += a[i]
	if sum1 >= m:
		print(i + 1)
		break


n = int(input())
m = int(input())
l = []
for i in range(n):
	k = int(input())
	l.append(k)
l.sort()
l.reverse()
summ = 1
sum = l[0]
for i in range(1, len(l)):
	if sum >= m:
		break
	sum += l[i]
	summ += 1
print(summ)


def main():
	n = int(input())
	m = int(input())
	a = [0] * n
	for i in range(n):
		a[i] = int(input())
	saved = 0
	i = 0
	a.sort(reverse=True)
	while saved < m:
		saved += a[i]
		i += 1
	print(i)
main()


n = int(input())
m = int(input())
drives = []
for i in range(n):
	drives.append(int(input()))
minimum_drives = 0
for drive in sorted(drives, reverse=True):
	minimum_drives += 1
	m -= drive
	if m <= 0:
		break
print(minimum_drives)


n = int(input())
maxSize = int(input())
sizes = []
for e in range(n):
	sizes.append(int(input()))
sizes.sort(reverse=True)
total = 0
num = 0
for e in sizes:
	if total < maxSize:
		total += e
		num += 1
print(num)


import string
n = int(input())
v = int(input())
a = []
z = 0
for i in range(n):
	a.append(int(input()))
a = sorted(a)
while v > 0:
	z = z + 1
	v = v - a[len(a) - z]
print(z)


count = int(input())
g = int(input())
lst = []
for i in range(count):
	lst.append(int(input()))
lst.sort()
lst.reverse()
temp = 0
i = -1
k = 0
while temp < g:
	i += 1
	temp += lst[i]
print(i + 1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	m = I()
	l = [I() for _ in range(n)]
	l.sort(reverse=True)
	for (i, x) in enumerate(l):
		m -= x
		if m <= 0:
			return i + 1
print(main())


n = int(input())
m = int(input())
l = []
ans = 0
while n > 0:
	d = int(input())
	l.append(d)
	n -= 1
l.sort()
l.reverse()
for i in l:
	m -= i
	ans += 1
	if m <= 0:
		break
print(ans)


def merge(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		merge(L)
		merge(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
merge(arr)
arr = arr[::-1]
cnt = 0
chk = 0
for i in arr:
	chk += i
	if chk < m:
		cnt += 1
	elif chk == m:
		print(cnt + 1)
		break
	else:
		print(cnt + 1)
		break


n = int(input())
m = int(input())
x = []
for i in range(n):
	x.append(int(input()))
x = list(reversed(sorted(x)))
s = 0
for i in range(len(x)):
	s += x[i]
	if s >= m:
		print(i + 1)
		break
if s < m:
	print(-1)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
n = qi()
m = qi()
a = []
for _ in range(n):
	a.append(qi())
k = 1
while sum(sorted(a)[::-1][:k]) < m:
	k += 1
print(k)


(a, b) = (int(input()), int(input()))
list1 = []
for i in range(a):
	list1.append(int(input()))
list1.sort(reverse=True)
n = 0
while b > 0:
	b -= list1[n]
	n += 1
print(n)


x = int(input())
f = int(input())
eyad = []
w = []
sol = 0
for i in range(x):
	a = int(input())
	eyad.append(a)
w = sorted(eyad, reverse=True)
for i in range(x):
	if f - w[i] <= 0:
		sol += 1
		break
	if f - w[i] > 0:
		sol += 1
		f -= w[i]
print(sol)


usbs = int(input())
fSize = int(input())
usbSize = []
for a in range(0, usbs):
	uSize = int(input())
	usbSize.append(uSize)
usbSize.sort()
a = 1
uSize = usbSize.pop()
while fSize > uSize:
	uSize = uSize + usbSize.pop()
	a = a + 1
print(a)


n = int(input())
m = int(input())
av = []
for i in range(n):
	av.append(int(input()))
av = sorted(av)[::-1]
count = 0
for i in range(n):
	m -= av[i]
	count += 1
	if m <= 0:
		break
print(count)


n = int(input())
m = int(input())
x = []
for i in range(n):
	val = int(input())
	x.append(val)
x = sorted(x)[::-1]
for (i, val) in enumerate(x):
	m -= val
	if m <= 0:
		print(i + 1)
		exit(0)


n = input()
n = int(n)
m = input()
m = int(m)
b = []
for i in range(n):
	a = input()
	b.append(int(a))
b.sort()
total = 0
c = []
for i in range(len(b)):
	total = total + b[len(b) - i - 1]
	c.append(0)
	if total >= m:
		break
print(len(c))


usbs = int(input())
file_size = int(input())
sizes = sorted([int(input()) for i in range(usbs)], reverse=True)
nos = 0
for s in sizes:
	if file_size > 0:
		file_size -= s
		nos += 1
print(nos)


n = int(input())
size = int(input())
USB = []
for i in range(n):
	USB.append(int(input()))
USB.sort()
USB.reverse()
tot = 0
num = 0
for i in USB:
	if tot < size:
		tot += i
		num += 1
	else:
		break
print(num)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
n = int(input())
m = int(input())
a = []
for x in range(n):
	a.append(int(input()))
a.sort(reverse=True)
for x in range(n):
	if m - a[x] > 0:
		m -= a[x]
	else:
		print(x + 1)
		exit()


n = int(input())
m = int(input())
a = [int(input()) for _ in range(n)]

def BubbleSort(n, a):
	for passnum in range(n - 1, 0, -1):
		for i in range(passnum):
			if a[i] > a[i + 1]:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
BubbleSort(n, a)
summa = 0
count = 0
for i in range(1, n + 1):
	if summa < m:
		summa += a[-i]
		count += 1
	elif summa >= m:
		break
print(count)


num = input()
file = int(input())
sizes = []
for i in range(int(num)):
	size = input()
	sizes.append(int(size))
sizes = sorted(sizes, reverse=True)
count = 0
while file > 0:
	file -= sizes[count]
	count += 1
print(count)


def Input():
	tem = input().split()
	ans = []
	for it in tem:
		ans.append(int(it))
	return ans
from collections import Counter
n = Input()[0]
m = Input()[0]
a = []
for i in range(n):
	a.append(Input()[0])
a.sort(reverse=True)
ans = 0
total = 0
for i in range(n):
	total += a[i]
	ans += 1
	if total >= m:
		break
print(ans)


tmp = []
for _ in range(2):
	tmp.append(int(input()))
USB_SIZE = []
for _ in range(tmp[0]):
	USB_SIZE.append(int(input()))
USB_SIZE.sort()
t = 0
for _ in range(len(USB_SIZE) - 1, -1, -1):
	tmp[1] -= USB_SIZE[_]
	t += 1
	if tmp[1] <= 0:
		print(t)
		exit()


import sys
numUSB = int(sys.stdin.readline())
fileSize = int(sys.stdin.readline())
counter = 0
usbs = []
for i in range(numUSB):
	usbs.append(int(sys.stdin.readline()))
usbs.sort(reverse=True)
for usb in usbs:
	if fileSize > 0:
		fileSize -= usb
		counter += 1
	else:
		break
print(counter)


x = int(input())
y = int(input())
z = []
for i in range(x):
	a = int(input())
	z.append(a)
z.sort()
z.reverse()
total = 0
total2 = 0
while total < y:
	total += z[0]
	z.remove(z[0])
	total2 += 1
print(total2)


def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
	return arr
n = int(input())
m = int(input())
arr = []
for i in range(n):
	arr += [int(input())]
arr = mergeSort(arr)
z = 0
x = 0
while z < m:
	z += arr[-1 - x]
	x += 1
print(x)


def binarySearch(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] >= x:
			if mid > 0 and arr[mid - 1] < x:
				return mid
			elif mid == 0:
				return 0
			elif arr[mid] == x:
				return mid
			elif arr[mid] < x:
				l = mid + 1
			else:
				r = mid - 1
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1
n = int(input())
m = int(input())
A = []
for _ in range(n):
	x = int(input())
	A.append(x)
A.sort(reverse=True)
a = []
x = 0
for val in A:
	x += val
	a.append(x)
x = binarySearch(a, 0, len(a), m)
print(x + 1)


n = int(input())
size = int(input())
l = []
s = count = 0
for x in range(n):
	l.append(int(input()))
l.sort()
for x in range(len(l) - 1, -1, -1):
	s = s + l[x]
	count += 1
	if s >= size:
		print(count)
		break


n = int(input())
k = int(input())
l = []
for i in range(0, n):
	l.append(int(input()))
l = sorted(l, reverse=True)
c = 0
while k > 0:
	k -= l[c]
	c += 1
print(c)


n = int(input())
m = int(input())
tmp = []
for i in range(n):
	ip = int(input())
	tmp.append(ip)
tmp.sort(reverse=True)
sum = 0
count = 0
for i in tmp:
	sum += i
	count += 1
	if sum >= m:
		print(count)
		exit()


n = eval(input())
m = eval(input())
i = 1
l = []
while i <= n:
	l = l + [eval(input())]
	i += 1
i = 0
while i <= len(l) - 2:
	if l[i + 1] > l[i]:
		tmp = l[i]
		l[i] = l[i + 1]
		l[i + 1] = tmp
		i = 0
	else:
		i += 1
i = 0
c = 0
sum = 0
while i <= len(l) - 1 and sum < m:
	sum = sum + l[i]
	c += 1
	i += 1
print(c)


n = int(input())
target = int(input())
l = []
while n:
	l.append(int(input()))
	n -= 1
l.sort(reverse=True)
cursum = 0
for i in range(len(l)):
	cursum += l[i]
	if cursum >= target:
		break
print(i + 1)


n = int(input())
m = int(input())
a = []
d = 0
k = 0
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
if a[0] > m:
	print(1)
else:
	for i in a:
		if m > 0:
			m -= i
			k += 1
		else:
			break
	print(k)


n = int(input())
m = int(input())
L = []
for i in range(n):
	L.append(int(input()))
L.sort()
L = L[::-1]
s = 0
i = 0
while s < m:
	s += L[i]
	i += 1
print(i)


n = int(input())
m = int(input())
l = []
sum1 = count = 0
for i in range(n):
	l.append(int(input()))
l.sort()
l.reverse()
for j in l:
	if sum1 < m:
		sum1 += j
		count += 1
	else:
		break
print(count)


n = int(input())
fl_sz = int(input())
lst = []
for i in range(0, n):
	d = int(input())
	lst.append(d)
lst.sort(reverse=True)
count = 0
for i in range(0, n):
	if fl_sz <= 0:
		break
	fl_sz = fl_sz - lst[i]
	count += 1
print(count)


n = int(input())
m = int(input())
capacities = []
for _ in range(n):
	capacities.append(int(input()))
capacities.sort(reverse=True)
counter = 0
sum_of_sizes = 0
index = 0
while sum_of_sizes < m:
	sum_of_sizes += capacities[index]
	counter += 1
	index += 1
print(counter)


N = int(input())
M = int(input())
A = []
for i in range(N):
	A.append(int(input()))
if any((e >= M for e in A)):
	print('1')
else:
	answer = 0
	A = sorted(A, reverse=True)
	i = 0
	while M > 0:
		M -= A[i]
		answer += 1
		i += 1
	print(answer)


usb_num = int(input())
data_size = int(input())
usb_list = []
x = 0
counter = 0
for i in range(usb_num):
	usb_list.append(int(input()))
usb_list.sort()
usb_list = usb_list[::-1]
for i in usb_list:
	x += i
	if x < data_size:
		counter += 1
	elif x >= data_size:
		counter += 1
		break
print(counter)


test = []
for i in range(int(input()) + 1):
	test.append(int(input()))
size = test[0]
test.remove(test[0])
test.sort(reverse=True)
c = 0
n = 0
while c < size:
	a = test[0]
	c = c + a
	n = n + 1
	test.remove(test[0])
print(n)


N = int(input())
W = int(input())
A = []
for i in range(0, N):
	A.append(int(input()))
A.sort()
A.reverse()
Summ = 0
N = 0
while W > Summ:
	Summ += A[N]
	N += 1
print(N)


n = int(input())
m = int(input())
sizes = []
for i in range(n):
	sizes.append(int(input()))
sizes.sort(reverse=True)
index = 0
while m > 0:
	m -= sizes[index]
	index += 1
print(index)


n = int(input())
m = int(input())
USB = []
for i in range(n):
	USB.append(int(input()))
USB.sort()
total_ = 0
USB.reverse()
for i in range(0, len(USB)):
	if m > 0:
		total_ += 1
		m -= USB[i]
	else:
		break
print(total_)


n = int(input())
m = int(input())
L = [int(input()) for _ in range(n)]
r = 1
L.sort()
while m > 0:
	m = m - L[n - r]
	r += 1
print(r - 1)


def countSort(list1):
	support = [0] * 1001
	result = []
	for element in list1:
		support[element] += 1
	for (i, element) in enumerate(support):
		if element > 0:
			for _ in range(element):
				result.append(i)
	return result
(n, m) = (int(input()), int(input()))
a = []
for i in range(n):
	a.append(int(input()))
a = countSort(a)[::-1]
s = 0
c = 0
while s < m:
	s += a[c]
	c += 1
print(c)


n = int(input())
m = int(input())
l = list()
for i in range(n):
	l.append(int(input()))
l.sort()
ans = 0
while m > 0:
	ans = ans + 1
	m = m - l.pop()
print(ans)


n = int(input())
z = int(input())
arr = []
for i in range(n):
	y = int(input())
	arr.append(y)
arr.sort(reverse=True)
count = 0
for i in range(n):
	count += arr[i]
	if count >= z:
		print(i + 1)
		break


import sys

def find_minimum_number_of_flash_drives(storage_sizes, filesize):
	n = len(storage_sizes)
	storage_sizes.sort(reverse=True)
	counter = 0
	for size in storage_sizes:
		filesize -= size
		counter += 1
		if filesize <= 0:
			break
	return counter
number_of_flash_drives = int(sys.stdin.readline().strip())
filesize = int(sys.stdin.readline().strip())
storage_sizes = []
for _ in range(number_of_flash_drives):
	storage_sizes.append(int(sys.stdin.readline().strip()))
sys.stdout.write(str(find_minimum_number_of_flash_drives(storage_sizes, filesize)) + '\n')


n = int(input())
m = int(input())
l = [int(input()) for i in range(n)]
l.sort(reverse=True)
sum = 0
i = 0
for elt in l:
	if sum < m:
		sum += elt
		i += 1
print(i)


n = int(input())
m = int(input())
a = []
for i in range(n):
	b = int(input())
	a.append(b)
a.sort()
a.reverse()
s = 0
k = 0
for i in range(n):
	s += a[i]
	k += 1
	if s >= m:
		break
print(k)


n = int(input())
m = int(input())
a = sorted([int(input()) for i in range(n)], reverse=True)
s = 0
for i in range(n):
	s += a[i]
	if s >= m:
		print(i + 1)
		exit()


USBs = int(input())
fileSize = int(input())
USBList = []
for USB in range(USBs):
	USBList.append(int(input()))
USBCount = 0
storedAmount = 0
while storedAmount < fileSize:
	USBCount += 1
	currentUSB = max(USBList)
	storedAmount += currentUSB
	USBList.remove(currentUSB)
print(USBCount)


n = int(input())
m = int(input())
k = sorted([int(input()) for i in range(n)])[::-1]
b = k[0]
s = 1
for i in range(1, n + 1):
	if b > m or b == m:
		print(s)
		break
	else:
		b += k[i]
		s += 1


def insertion_sort(l):
	for i in range(len(l)):
		for j in range(i):
			k = i - j
			if l[k] >= l[k - 1]:
				(l[k - 1], l[k]) = (l[k], l[k - 1])
			else:
				break
	return l

def selection_sort(l):
	for i in range(len(l)):
		min_ind = i
		min_val = l[i]
		for j in range(i, len(l)):
			if min_val > l[j]:
				min_val = l[j]
				min_ind = j
		(l[i], l[min_ind]) = (l[min_ind], l[i])
	return l

def bubble_sort(l):
	for i in range(len(l) - 1):
		for j in range(len(l) - 1 - i):
			if l[j] > l[j + 1]:
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	return l

def main_function():
	n = int(input())
	m = int(input())
	a = []
	for i in range(n):
		a_i = int(input())
		a.append(a_i)
	sorted_a = insertion_sort(a)
	sum = 0
	count = 0
	for i in a:
		if sum >= m:
			return count
		else:
			sum += i
			count += 1
	return count
print(main_function())


import logging
import copy
import sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

def solve(m, lines):
	lines.sort()
	lines.reverse()
	s = 0
	for (i, n) in enumerate(lines):
		s += n
		if s >= m:
			return i + 1

def main():
	n = int(input())
	m = int(input())
	inputLines = []
	for i in range(n):
		line = int(input())
		inputLines.append(line)
	print(solve(m, inputLines))

def log(*message):
	logging.debug(message)
main()


def read_ints():
	return list(map(int, input().split()))
flashCount = read_ints()[0]
fileSize = read_ints()[0]
flashes = []
for i in range(0, flashCount):
	flashes.append(read_ints()[0])
flashes = sorted(flashes, reverse=True)
sizeOnFlashes = 0
counter = 0
for i in flashes:
	sizeOnFlashes += i
	counter += 1
	if sizeOnFlashes >= fileSize:
		break
print(counter)


n = int(input())
m = int(input())
l = []
i = -1
j = 0
ans = 0
for i in range(n):
	s = int(input())
	l.append(s)
l.sort()
while j < m:
	j += l[i]
	i -= 1
	ans += 1
print(ans)


drives_cnt = int(input())
file = int(input())
drives = []
used_drives = []
for i in range(drives_cnt):
	drives.append(int(input()))
sums = 0
j = 0
while sums < file and j < drives_cnt:
	val = sorted(drives, reverse=True)[j]
	sums = sums + val
	used_drives.append(j)
	j = j + 1
print(len(used_drives))


x = int(input())
y = int(input())
z = []
for i in range(x):
	z.append(int(input()))
z.sort()
j = 0
while y > 0:
	y -= z[x - 1 - j]
	j += 1
print(j)


n = int(input())
m = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a.sort(reverse=True)
result = 0
c = 0
for i in a:
	result += i
	c += 1
	if result >= m:
		break
print(c)


n = int(input())
file_size = int(input())
cards = []
count = 0
while n > 0:
	cards.append(int(input()))
	n -= 1

def partition(arr, low, high):
	i = low - 1
	pivot = arr[high]
	for j in range(low, high):
		if arr[j] <= pivot:
			i = i + 1
			(arr[i], arr[j]) = (arr[j], arr[i])
	(arr[i + 1], arr[high]) = (arr[high], arr[i + 1])
	return i + 1

def quick_sort(arr, low, high):
	if low < high:
		p_i = partition(arr, low, high)
		quick_sort(arr, low, p_i - 1)
		quick_sort(arr, p_i + 1, high)
n = len(cards)
quick_sort(cards, 0, n - 1)
cards.reverse()
for card in cards:
	file_size -= card
	count += 1
	if file_size <= 0:
		break
print(count)


n = int(input())
m = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
a = sorted(a)
a.reverse()
ans = 0
sums = 0
i = 0
while sums < m:
	sums += a[i]
	ans += 1
	i += 1
print(ans)


n = int(input())
s = int(input())
l_d = list()
for _ in range(n):
	l_d.append(int(input()))
l_d.sort(reverse=True)
c = 0
t = 0
while s > c and t < n:
	c += l_d[t]
	t += 1
print(t)


f = lambda : int(input())
(n, k) = (f(), f())
p = sorted([f() for case in ' ' * n], reverse=True)
i = 1
while sum(p[:i]) < k:
	i += 1
print(i)


n = int(input())
m = int(input())
drives = [0 for _ in range(1001)]
for _ in range(n):
	drives[int(input())] += 1
qty = 0
for i in range(1000, -1, -1):
	while 0 < drives[i] and m > 0:
		drives[i] -= 1
		m -= i
		qty += 1
print(qty)


n = int(input())
m = int(input())
lst = []
for i in range(n):
	lst.append(int(input()))
lst.sort()
res = 0
sum1 = 0
for i in range(n - 1, -1, -1):
	sum1 += lst[i]
	res += 1
	if sum1 >= m:
		print(res)
		break


b = int(input())
c = int(input())
a = []
(k1, k) = (0, 0)
for i in range(b):
	a += (int(input()),)
a.sort()
while k < c:
	k1 += 1
	k += a[-k1]
print(k1)


n = int(input())
m = int(input())
c = []
for i in range(n):
	c.append(int(input()))
c.sort()
s = 0
p = 0
for i in range(n - 1, -1, -1):
	s += c[i]
	p += 1
	if s >= m:
		print(p)
		break


A = []
i = -1
x = int(input())
y = int(input())
for x in range(x):
	a = int(input())
	A.append(a)
A.sort()
a = 0
while A[i] >= -len(A):
	y = y - A[i]
	a += 1
	i -= 1
	if y <= 0:
		break
print(a)


i = lambda : int(input())
(n, m) = (i(), i())
a = sorted([i() for x in range(n)], reverse=1)
print(next((k + 1 for k in range(n) if sum(a[:k + 1]) >= m)))


number_of_drives = int(input())
file_size = int(input())
stick_sizes = []
while number_of_drives > 0:
	stick_sizes.append(int(input()))
	number_of_drives -= 1
stick_sizes.sort()
req_num_of_sticks = 0
while file_size > 0:
	req_num_of_sticks += 1
	file_size -= stick_sizes.pop()
print(req_num_of_sticks)