Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea.

Amr has n instruments, it takes a_{i} days to learn i-th instrument. Being busy, Amr dedicated k days to learn how to play the maximum possible number of instruments.

Amr asked for your help to distribute his free days between instruments so that he can achieve his goal.


-----Input-----

The first line contains two numbers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10 000), the number of instruments and number of days respectively.

The second line contains n integers a_{i} (1 ≤ a_{i} ≤ 100), representing number of days required to learn the i-th instrument.


-----Output-----

In the first line output one integer m representing the maximum number of instruments Amr can learn.

In the second line output m space-separated integers: the indices of instruments to be learnt. You may output indices in any order.

if there are multiple optimal solutions output any. It is not necessary to use all days for studying.


-----Examples-----
Input
4 10
4 3 1 2

Output
4
1 2 3 4
Input
5 6
4 3 1 1 2

Output
3
1 3 4
Input
1 3
4

Output
0



-----Note-----

In the first test Amr can learn all 4 instruments.

In the second test other possible solutions are: {2, 3, 5} or {3, 4, 5}.

In the third test Amr doesn't have enough time to learn the only presented instrument.

Difficulty: EASY
Tags: Sorting

Implementation

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
__author__ = 'Ismail_A'
import math

def read():
	inputs = input().strip()
	return list(map(int, inputs.split()))

def read_pair():
	return map(int, input().split(' '))
(n, k) = read_pair()
a = read()
b = []
for i in range(n):
	b.append((a[i], i))
b = sorted(b)
ans = []
for i in range(n):
	if k < b[i][0]:
		break
	else:
		ans.append(b[i][1] + 1)
		k -= b[i][0]
print(len(ans))
for i in range(len(ans)):
	print(ans[i], end=' ')


(n, k) = [int(x) for x in input().split()]
s = input().split()
l = []
for i in range(n):
	l.append((int(s[i]), i + 1))
l.sort(key=lambda x: x[0])
left = 0
right = 0
summ = 0
flag = 0
ans = []
elem = 0
while left <= right and right < n:
	while summ <= k:
		summ += l[right][0]
		if summ <= k:
			ans.append(l[right][1])
			elem += 1
			flag = 1
		right += 1
		if right >= n:
			break
	break
print(elem)
if flag == 1:
	for i in sorted(ans):
		print(i, end=' ')


import sys

def main():
	[k, n] = list(map(int, sys.stdin.readline().split()))
	instr_list = list(map(int, sys.stdin.readline().split()))
	arr1 = [(x, i + 1) for (i, x) in enumerate(instr_list)]
	arr2 = sorted(arr1)
	summ = 0
	res = []
	for (x, pos) in arr2:
		if summ + x > n:
			break
		else:
			summ += x
			res.append(pos)
	print(len(res))
	if res:
		print(' '.join(map(str, res)))
main()


(instr, days) = (int(x) for x in input().split())
arr = [(int(y), x + 1) for (x, y) in enumerate(input().split())]
arr.sort()
if arr[0][0] > days:
	print(0)
else:
	result = []
	for hard in arr:
		days -= hard[0]
		if days >= 0:
			result.append(str(hard[1]))
		else:
			break
	print(len(result))
	print(' '.join(result))


(n, k) = map(int, input().split())
lst = [int(i) for i in input().split()]
suma = 0
db = []
while suma + min(lst) <= k:
	if min(lst) == 101:
		break
	else:
		suma += min(lst)
		db.append(str(lst.index(min(lst)) + 1))
		lst[lst.index(min(lst))] = 101
print('{}\n{}'.format(len(db), ' '.join(db)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [i for i in a]
b.sort()
c = []
for i in b:
	if k - i >= 0:
		k -= i
		for j in range(len(a)):
			if a[j] == i and j + 1 not in c:
				c.append(j + 1)
				break
print(len(c))
s = ''
for i in c:
	s += str(i) + ' '
if s != '':
	print(s[:len(s) - 1])


(N, K) = map(int, input().split())
A = [(i + 1, int(x)) for (i, x) in enumerate(input().split())]
A.sort(key=lambda t: t[1])
answer = []
for t in A:
	if t[1] > K:
		break
	answer.append(t[0])
	K -= t[1]
print(len(answer))
print(*answer)


[n, days] = list(map(int, input().split()))
a_list = list(map(int, input().split()))
out_list = []
sum = 0
visit_list = []

def find_min(a_list):
	min = 10001
	index = -1
	for i in range(len(a_list)):
		if a_list[i] < min and i not in visit_list:
			min = a_list[i]
			index = i
	if min < 10001:
		visit_list.append(index)
		return index
	else:
		return -1
while n:
	a = find_min(a_list)
	if a >= 0 and a_list[a] <= days:
		out_list.append(str(a + 1))
		days -= a_list[a]
		sum += 1
	else:
		break
print(sum)
if out_list:
	print(' '.join(out_list))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = [(arr[i], i) for i in range(n)]
arr.sort()
t = 0
res = []
for i in arr:
	res.append(i)
	if sum([i[0] for i in res]) > k:
		res = res[:-1]
		break
if len(res) == 0:
	print('0')
else:
	print(len(res))
	print(' '.join([str(i[1] + 1) for i in res]))


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def revn(n):
	m = 0
	while n > 0:
		m = m * 10 + n % 10
		n = n // 10
	return m
(n, k) = mi()
a = li()
t = []
for i in range(n):
	t.append([a[i], i + 1])
t.sort()
ans = []
d = 0
for i in range(n):
	if d + t[i][0] <= k:
		d += t[i][0]
		ans.append(t[i][1])
print(len(ans))
print(' '.join(map(str, ans)))


(x, y) = map(int, input().split(' '))
z = sorted([(k, i + 1) for (i, k) in enumerate(map(int, input().split(' ')))])
b = []
for i in range(x):
	if z[i][0] > y:
		break
	b.append(z[i][1])
	y = y - z[i][0]
print(len(b))
print(*b)


(n, b) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = sorted(a)
s = 0
e = 0
for i in range(0, len(d)):
	s = s + d[i]
	e = e + 1
	if s > b:
		s = s - d[i]
		e = e - 1
		break
	else:
		pass
l = []
g = 0
while len(l) < e:
	for j in range(0, len(a)):
		if a[j] == d[g] and j + 1 not in l:
			l.append(j + 1)
			break
	g = g + 1
	if len(l) == e:
		break
print(e)
print(*l)


import heapq
(nInstruments, nDays) = [int(x) for x in input().split()]
instr = [int(x) for x in input().split()]
indInst = [[instr[i], i + 1] for i in range(nInstruments)]
heapq.heapify(indInst)
days = 0
learned = []
while len(indInst) > 0:
	nextInst = heapq.heappop(indInst)
	days += nextInst[0]
	if days > nDays:
		break
	learned.append(nextInst[1])
print(len(learned))
for ind in learned:
	print(ind, end=' ')
print()


(n, k) = map(int, input().split())
sum = 0
lstrs = []
for (a, b) in sorted(zip(map(int, input().split()), range(1, n + 1))):
	sum += a
	if sum > k:
		break
	lstrs.append(str(b))
print(len(lstrs))
print(' '.join(lstrs))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l1 = sorted(l)
z = []
(c, c1) = (0, 0)
for i in l1:
	if c + i <= k:
		c1 += 1
		c += i
		z.append(i)
c = 0
print(c1)
for i in l:
	if c1 == 0:
		break
	if i in z:
		c1 -= 1
		print(c + 1, end=' ')
	c += 1


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = a.copy()
a.sort()
i = 0
c = 0
l = []
while k > 0 and i < n:
	if a[i] <= k:
		k -= a[i]
		ind = s.index(a[i])
		l.append(ind + 1)
		s[ind] = -1
		c += 1
		i += 1
	else:
		break
print(c)
print(*l)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = [[i, j] for (i, j) in enumerate(arr)]
arr = sorted(arr, key=lambda x: x[1])
out = []
for i in range(n):
	if arr[i][1] <= k:
		k -= arr[i][1]
		out.append(arr[i][0] + 1)
	else:
		break
print(len(out))
print(*out)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
for i in range(n):
	L[i] = (L[i], i)
L.sort()
ans = 0
A = []
ind = 0
while ind < len(L) and k >= L[ind][0]:
	ans += 1
	A.append(L[ind][1] + 1)
	k -= L[ind][0]
	ind += 1
print(ans)
for item in A:
	print(item, end=' ')


import operator
x = input().split()
a = []
b = []
lim = int(x[1])
b = input().split(' ')
for i in range(int(x[0])):
	a.append([int(b[i]), i])
a.sort(key=operator.itemgetter(0, 1))
i = 0
while lim > 0 and i < int(x[0]):
	lim -= a[i][0]
	i = i + 1
if lim < 0:
	i -= 1
j = i
s = ''
print(i)
for i in range(j):
	print(a[i][1] + 1, end=' ')


(n, k) = map(int, input().split())
inst = list(map(int, input().split()))
instS = sorted(inst)
i = 0
masInd = []
kol = 0
while i < n and instS[i] <= k:
	kol += 1
	ind = inst.index(instS[i])
	inst[ind] = instS[-1] + 1
	masInd.append(ind + 1)
	k -= instS[i]
	i += 1
print(kol)
for i in masInd:
	print(i, end=' ')


(n, k) = input().split()
(n, k) = (int(n), int(k))
lis = input().split()
for i in range(n):
	lis[i] = [int(lis[i]), i + 1]
lis.sort()
s = 0
c = 0
for i in range(n):
	s += lis[i][0]
	if s <= k:
		c += 1
print(c)
if c > 0:
	for i in range(c):
		print(lis[i][1], end=' ')


(n, k) = map(int, input().split())
sol = []
for (a, b) in sorted(zip(map(int, input().split()), range(1, n + 1))):
	if k >= a:
		k -= a
		sol.append(b)
print(len(sol))
print(' '.join(map(str, sol)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
g = 0
if sum(a) > k:
	while sum(a) > k:
		a[a.index(max(a))] = 0
	for i in range(0, len(a)):
		if a[i] != 0:
			g += 1
	print(g)
	for i in range(0, len(a)):
		if a[i] != 0:
			print(i + 1, sep='', end=' ')
else:
	print(len(a))
	for i in range(0, len(a)):
		print(i + 1)


nk = input()
(n_str, k_str) = list(map(int, nk.split(' ')))
n = int(n_str)
k = int(k_str)
instr_str = input()
ins = list(map(int, instr_str.split(' ')))
instr = [[ins[i], i + 1] for i in range(n)]
instr.sort(key=lambda l: l[0])
ans = []
while instr and k >= instr[0][0]:
	k = k - instr[0][0]
	ans.append(str(instr.pop(0)[1]))
print(len(ans))
print(' '.join(ans))


(n, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
index = []
for i in range(n):
	index.append(i + 1)
for i in range(n):
	for j in range(i + 1, n):
		if nums[i] > nums[j]:
			temp = nums[i]
			nums[i] = nums[j]
			nums[j] = temp
			temp = index[i]
			index[i] = index[j]
			index[j] = temp
sum = 0
temp = 0
res = ''
for i in range(n):
	if sum + nums[i] <= k:
		res += str(index[i]) + ' '
		sum += nums[i]
		temp += 1
	else:
		break
if res != '':
	print(temp)
print('0' if res == '' else res)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
c = 0
l = []
for i in range(n):
	l.append([d[i], i + 1])
l.sort()
x = []
for i in l:
	k = k - i[0]
	if k < 0:
		break
	c = c + 1
	x.append(i[1])
if c == 0:
	print(0)
else:
	print(c)
	print(*x)


(a, b) = map(int, input().split())
i = 1
instruments = []
for time in map(int, input().split()):
	instruments.append([time, i])
	i += 1
instruments.sort()
i = 0
res_list = []
cur_sum = 0
while i < a and cur_sum + instruments[i][0] <= b:
	res_list.append(instruments[i][1])
	cur_sum += instruments[i][0]
	i += 1
print(len(res_list))
print(*res_list)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
av = sorted(zip(a, range(1, n + 1)))
ans = 0
for elem in av:
	if k - elem[0] < 0:
		break
	else:
		k -= elem[0]
		ans += 1
print(ans)
for i in range(ans):
	print(av[i][1], end=' ')


(n, k) = map(int, input().split())
ms = sorted([[int(m), i] for (i, m) in enumerate(input().split())])
r = []
for m in ms:
	if k - m[0] >= 0:
		k -= m[0]
		r.append(m[1] + 1)
print(len(r))
print(' '.join(map(str, r)))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
original = arr.copy()
arr.sort()
temp = []
for i in range(n):
	if arr[i] <= k:
		temp.append(original.index(arr[i]) + 1)
		ans = original.index(arr[i])
		original[ans] = 'X'
		k -= arr[i]
	else:
		break
print(len(temp))
print(*temp)


(n, k) = map(int, input().split())
l = zip(list(map(int, input().split())), range(1, n + 1))
l = sorted(l, key=lambda x: x[0])
a = []
for (j, i) in l:
	k -= j
	if k >= 0:
		a.append(i)
print(len(a))
print(*a)


a = list(map(int, input().split()))
n = a[0]
k = a[1]
s = set()
x = list(map(int, input().split()))
for i in range(0, n):
	s.add((i + 1, x[i]))

def getkey(item):
	return item[1]
l = sorted(s, key=getkey)
summ = 0
chk = 0
for j in range(0, n):
	if summ + l[j][1] <= k:
		summ += l[j][1]
	else:
		chk += 1
		break
if not chk:
	j = n
print(j)
for i in range(0, j):
	print(l[i][0], end=' ')


(n, t) = map(int, input().split(' '))
d = {}
a = [int(i) for i in input().split(' ')]
for i in range(n):
	d.setdefault(a[i], []).append(i + 1)
a.sort()
s = i = 0
f = []
while s <= t and i < n:
	if s + a[i] <= t:
		s += a[i]
		f.append(d[a[i]].pop(0))
	i += 1
print(len(f))
if len(f):
	print(' '.join(map(str, f)))


(n, k) = map(int, input().split())
array = list(map(int, input().split()))
array_1 = sorted([[num, pos] for (pos, num) in enumerate(array)])
array_2 = []
for i in array_1:
	if k - i[0] >= 0:
		array_2.append(i[1] + 1)
		k -= i[0]
	else:
		break
print(len(array_2))
print(*array_2)


(n, k) = map(int, input().split())
arr = sorted(((int(x), i + 1) for (x, i) in zip(input().split(), range(n))))
res = []
for (x, i) in arr:
	if x <= k:
		k -= x
		res.append(str(i))
print(len(res))
print(' '.join(res))


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
a = sorted([(b[i], i + 1) for i in range(len(b))])
ans = 0
s = 0
c = []
for i in range(len(a)):
	if s + a[i][0] <= k:
		ans += 1
		s += a[i][0]
		c += [str(a[i][1])]
	else:
		break
print(ans)
print(' '.join(c))


(n, k) = map(int, input().split())
a = input().split()

def ke(n):
	return n[1]
for i in range(n):
	a[i] = [i, int(a[i])]
a.sort(key=ke)
s = 0
i = 0
answ = 0
answ_v = []
while True:
	if i == n:
		break
	if s + a[i][1] > k:
		break
	s += a[i][1]
	answ += 1
	answ_v.append(a[i][0] + 1)
	i += 1
print(answ)
for i in answ_v:
	print(i, end=' ')


from operator import itemgetter

class CodeforcesTask507ASolution:

	def __init__(self):
		self.result = ''
		self.n_k = []
		self.instruments = []

	def read_input(self):
		self.n_k = [int(x) for x in input().split(' ')]
		self.instruments = [int(x) for x in input().split(' ')]

	def process_task(self):
		instru = [(x + 1, self.instruments[x]) for x in range(self.n_k[0])]
		instru.sort(key=itemgetter(1))
		time = self.n_k[1]
		result = 0
		x = 0
		while time and x < self.n_k[0]:
			if time - instru[x][1] >= 0:
				result += 1
				time -= instru[x][1]
				x += 1
			else:
				time = 0
		self.result = '{0}\n{1}'.format(result, ' '.join([str(x) for x in [y[0] for y in instru[:result]]]))

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


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append((a[i], i + 1))
b.sort()
countd = 0
c = []
for i in b:
	countd += i[0]
	if countd > k:
		break
	c.append(i[1])
print(len(c))
print(*c)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = [a[i], i]
a.sort()
ans = []
for i in range(n):
	if a[i][0] <= k:
		k -= a[i][0]
		ans.append([a[i][0], a[i][1] + 1])
print(len(ans))
for i in range(len(ans)):
	print(ans[i][1], end=' ')


from _ast import Str
n = input()
n = n.split(' ')
for i in range(0, 2):
	n[i] = int(n[i])
b = input()
b = b.split(' ')
c = []
for i in range(0, n[0]):
	b[i] = int(b[i])
	c.append(i)
	c[i] = c[i] + 1
for j in range(0, n[0]):
	for i in range(0, n[0] - 1):
		if b[i] > b[i + 1]:
			(b[i], b[i + 1]) = (b[i + 1], b[i])
			(c[i], c[i + 1]) = (c[i + 1], c[i])
Sum = 0
d = ''
flag = 0
count = 0
for i in range(0, n[0]):
	if Sum + b[i] <= n[1]:
		Sum = Sum + b[i]
		count += 1
		if flag == 0:
			d += str(c[i])
			flag = 1
		else:
			d += ' ' + str(c[i])
	else:
		break
print(count)
print(d)


import sys, math, cmath, time, collections
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import nsmallest, nlargest, heapify, heappop, heappush, heapreplace
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi
from bisect import bisect_left, bisect_right

def input_as_array():
	return list(map(int, input().split()))
start_time = time.time()

def solve(arr, n, k):
	g = defaultdict(list)
	for (i, c) in enumerate(arr, 1):
		g[c].append(i)
	arr.sort()
	s = 0
	i = 0
	while i < n:
		if s + arr[i] <= k:
			s += arr[i]
		else:
			break
		i += 1
	print(i)
	required = arr[:i]
	op = []
	ctr = Counter(required)
	for (k, v) in ctr.items():
		op.append(g[k][:v])
	flatten = [k for c in op for k in c]
	print(*flatten)

def main():
	(n, k) = map(int, input().split())
	arr = input_as_array()
	solve(arr, n, k)
LOCAL = False
if LOCAL:
	sys.stdin = open('../io/data.in', 'r')
	sys.stdout = open('../io/data.out', 'w')
testcases = 1
for i in range(testcases):
	main()
if LOCAL:
	print(f'Time Elapsed: {time.time() - start_time} seconds')
	sys.stdout.close()


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(n):
	a += [[b[i], i + 1]]
a.sort()
sum = 0
sol = 0
tab = []
for i in range(n):
	if sum + a[i][0] <= k:
		sum += a[i][0]
		tab += [a[i][1]]
		sol += 1
	else:
		break
print(sol)
for i in range(len(tab)):
	print(tab[i], end=' ')
print()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
sum = 0
i = 0
for i in range(len(a)):
	sum = sum + b[i]
	if sum > k:
		i = i - 1
		break
print(i + 1)
for i in b[0:i + 1]:
	print(a.index(i) + 1, end=' ')
	a[a.index(i)] = -1


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
q = [[1000000000, 10000]]
ans = 0
s = ''
for i in range(n):
	q.append([l[i], i + 1])
q = list(sorted(q))
while q[0][0] <= k:
	k -= q[0][0]
	ans += 1
	s += str(q[0][1]) + ' '
	q.pop(0)
print(ans)
print(s.strip())


(n, m) = map(int, input().split(' '))
arr = [int(i) for i in input().split(' ')]
for i in range(n):
	arr[i] = (arr[i], i + 1)
arr.sort()
res = []
for (i, j) in arr:
	if m >= i:
		m -= i
		res.append(j)
print(len(res))
for i in res:
	print(i, end=' ')


def recursie(s, i):
	if i < n and s + p[i][1] <= k:
		recursie(s + p[i][1], i + 1)
		print(p[i][0] + 1, sep=' ', end=' ')
	else:
		print(i)
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = []
for i in range(n):
	p.append([i, l[i]])
p = sorted(p, key=lambda x: x[1])
s = 0
i = 0
recursie(s, i)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
c = list(a)
c.sort()
l = []
cnt = 0
p = 0
for i in range(n):
	cnt += c[i]
	if cnt <= k:
		p += 1
		l.append(a.index(c[i]) + 1)
		a[a.index(c[i])] = '#'
if p == 0:
	print(0)
else:
	print(p)
	print(*l)


(n, days) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
if min(a) > days:
	print(0)
	exit()
a_index = [i for i in range(1, n + 1)]
zipped = sorted(zip(a, a_index))
ans = []
sorted_a = [i for (i, _) in zipped]
sorted_index = [i for (_, i) in zipped]
for i in range(n):
	if days >= sorted_a[i]:
		ans.append(sorted_index[i])
		days -= sorted_a[i]
print(len(ans))
print(*ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [(i + 1, x) for (i, x) in enumerate(a)]
a = sorted(a, key=lambda x: x[1])
ans = []
for i in range(len(a)):
	if a[i][1] <= k:
		ans.append(a[i][0])
		k -= a[i][1]
print(len(ans))
if len(ans) > 0:
	print(' '.join(map(str, ans)))


from operator import itemgetter
__author__ = 'Konrad Strack'

def solve():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	indexed = [(i + 1, x) for (i, x) in enumerate(a)]
	sum = 0
	selected = []
	for (i, v) in sorted(indexed, key=itemgetter(1)):
		if sum + v <= k:
			sum += v
			selected.append(str(i))
		else:
			break
	print(len(selected))
	if len(selected) > 0:
		print(' '.join(selected))

def __starting_point():
	solve()
__starting_point()


(n_instruments, days) = map(int, input().split())
instruments = list(map(int, input().split()))
instruments = [[_ + 1, instruments[_]] for _ in range(n_instruments)]
instruments.sort(key=lambda x: x[1])
learned_instruments = []
for i in range(n_instruments):
	if sum([instruments[_][1] for _ in range(i + 1)]) <= days:
		learned_instruments.append(instruments[i][0])
	else:
		break
print(len(learned_instruments))
if len(learned_instruments) > 0:
	print(*learned_instruments)


(n, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
arr = list(enumerate(arr))
arr.sort(key=lambda x: x[1])
d = 0
ans = []
for i in range(len(arr)):
	d += arr[i][1]
	if d > k:
		break
	ans.append(arr[i][0] + 1)
print(len(ans))
print(' '.join(map(str, ans)))


(n, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
a = [(x, i) for (i, x) in enumerate(a)]
a.sort(reverse=True)
r = []
while k > 0 and a:
	x = a.pop()
	if k >= x[0]:
		k -= x[0]
		r.append(x[1] + 1)
print(len(r))
if r:
	print(*r)


(n, k) = map(int, input().split())
a = [0] * n
d = list(map(int, input().split()))
for i in range(n):
	a[i] = i + 1
s = sorted(zip(d, a))
l_o = list()
i = 0
while i < len(s) and k - s[i][0] >= 0:
	k -= s[i][0]
	l_o.append(s[i][1])
	i += 1
print(i)
for o in l_o:
	print(o, end=' ')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
a = array()
a = [(a[i], i) for i in range(n)]
a.sort()
ans = []
for i in range(n):
	if k >= a[i][0]:
		ans.append(a[i][1] + 1)
		k -= a[i][0]
print(len(ans))
print(*ans)


(n, k) = list(map(int, input().split()))
ar = list(map(int, input().split()))
ar2 = sorted(ar)
ar3 = sorted(list(enumerate(ar)), key=lambda pair: pair[1])
x = max((i for i in range(len(ar2) + 1) if sum(ar2[:i]) <= k))
print(x)
print(' '.join([str(pair[0] + 1) for pair in ar3[:x]]))


(n, k1) = map(int, input('').split())
m = list(map(int, input('').split()))
k = 1
z = []
for i in m:
	z += [(i, k)]
	k = k + 1
z.sort()
p = 0
count = 0
y = ''
for (i, q) in z:
	if p + i <= k1:
		count = count + 1
		p = p + i
		y += str(q) + ' '
print(count)
print(y)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = [[0, 0]] * len(a)
for i in range(len(a)):
	d[i] = [a[i], i]

def f1(d):
	return d[0]
d.sort(key=f1)
res = []
nas = 0
for i in range(len(d)):
	if k >= d[i][0]:
		k -= d[i][0]
		res.append(d[i][1] + 1)
		nas += 1
print(nas)
if nas > 0:
	print(' '.join(map(str, res)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
t = 0
i = []
while t < k and a.count(101) != len(a):
	if t + min(a) > k:
		a[a.index(min(a))] = 101
	else:
		t += min(a)
		i.append(a.index(min(a)) + 1)
		a[a.index(min(a))] = 101
print(len(i))
print(*i)


from sys import stdin
(n, k) = map(int, stdin.readline().split())
a = sorted(zip(map(int, stdin.readline().split()), range(1, n + 1)))
s = 0
l = []
for i in a:
	s += i[0]
	if s <= k:
		l.append(i[1])
print(len(l))
print(*l)


(n, k) = map(int, input().split())
ar = [int(x) for x in input().split()]
a = []
for x in range(n):
	i = ar[x]
	a.append((i, x + 1))
a.sort()
sumo = 0
ans = []
for i in range(n):
	if a[i][0] + sumo > k:
		break
	else:
		ans.append(a[i])
		sumo += a[i][0]
print(len(ans))
for i in range(len(ans)):
	print(ans[i][1], end=' ')


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = 0
ans = []
ans_ = []
b = sorted(a)
for B in b:
	if s + B <= k:
		s += B
		ans_.append(B)
	else:
		break
len_ans_ = len(ans_)
if len_ans_ == 0:
	print(0)
	return
ans.append(a.index(ans_[0]) + 1)
for i in range(1, len_ans_):
	if ans_[i] == ans_[i - 1]:
		ans.append(a[ans[-1]:].index(ans_[i]) + ans[-1] + 1)
	else:
		ans.append(a.index(ans_[i]) + 1)
ans.sort()
print(len(ans))
if len(ans) > 0:
	print(*ans)


(n, k) = map(int, input().split())
data = list(map(int, input().split()))
for i in range(n):
	data[i] = [data[i], i + 1]
data.sort()
current_cnt = 0
answer = []
for i in range(n):
	if current_cnt + data[i][0] <= k:
		answer.append(data[i][1])
		current_cnt += data[i][0]
print(len(answer))
if len(answer) > 0:
	print(' '.join(map(str, answer)))


import sys
input = sys.stdin.readline
(m, n) = map(int, input().split())
a = list(map(int, input().split()))
k = []
while len(k) < m and min(a) <= n:
	for i in range(len(a)):
		if a[i] == min(a):
			n -= a[i]
			k.append(i + 1)
			a[i] = n + 1
			break
print(len(k))
print(*k)


(x, y) = list(map(int, input().split()))
arr = list(map(int, input().split()))
copy = list(arr)
arr = sorted(arr)
(count, i) = (0, 0)
res = []
while (count <= y) & (i < x):
	if count + arr[i] <= y:
		res.append(copy.index(arr[i]) + 1)
		copy[copy.index(arr[i])] = -1
		count += arr[i]
		i += 1
	else:
		break
print(i)
if i != 0:
	res = map(str, res)
	print(' '.join(res))


cnt = 1
su = 0
r = []
q = []
x = []
p = 0

def init(a):
	for p in range(len(a)):
		a[p] = int(a[p])
	return a
(n, k) = input().split()
n = int(n)
k = int(k)
a = input().split()
a = init(a)
for l in range(len(a)):
	r.append(a[l])
if sum(a) <= k:
	print(n, end='\n')
	for i in range(1, n + 1):
		print(i, end=' ')
elif sum(a) > k:
	while sum(a) > k:
		a.remove(int(max(a)))
	print(len(a))
	if len(a) >= 1:
		for i in range(len(r)):
			if p < len(a) and r[i] == a[p]:
				print(i + 1, end=' ')
				p = p + 1


(n, k) = [int(x) for x in input().split()]
s = input().split()
l = []
for i in range(n):
	l.append((int(s[i]), i + 1))
l.sort(key=lambda x: x[0])
lt = 0
rt = 0
sum = 0
flag = 0
ans = []
elem = 0
while lt <= rt and rt < n:
	while sum <= k:
		sum += l[rt][0]
		if sum <= k:
			ans.append(l[rt][1])
			elem += 1
			flag = 1
		rt += 1
		if rt >= n:
			break
	break
print(elem)
if flag == 1:
	for i in sorted(ans):
		print(i, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sorted(a)
res = []
for i in range(n):
	k -= s[i]
	if k < 0:
		break
	res += [str(a.index(s[i]) + 1)]
	a[a.index(s[i])] = 0
print(len(res))
print(' '.join(res))


(n, k) = map(int, input().split())
lis = [int(x) for x in input().split()]
lisSorted = sorted(lis)
resIndex = []
for i in lisSorted:
	if i <= k:
		k -= i
		resIndex.append(lis.index(i) + 1)
		lis[lis.index(i)] = 99999999
if len(resIndex) > 0:
	print(len(resIndex))
	print(*resIndex)
else:
	print(0)


(n, k) = map(int, input().split(' '))
i = 0
days = [int(x) for x in input().split(' ')]
for x in range(0, n):
	days[x] = (days[x], i + 1)
	i += 1
sorted_days = days[:]
sorted_days.sort()
days_num = 0
res = 0
indexes = ''
for i in range(n):
	days_num += sorted_days[i][0]
	if days_num <= k:
		indexes += str(sorted_days[i][1]) + ' '
		res += 1
	else:
		break
if res == 0:
	print(res)
else:
	print('{0}\n{1}'.format(res, indexes.strip()))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = []
b = sorted(a)
if k >= b[0]:
	for i in range(n - 1):
		if k <= 0:
			break
		elif k - b[i] >= b[i + 1]:
			c.append(a.index(b[i]) + 1)
			k = k - b[i]
			a[a.index(b[i])] = 101
		elif k - b[i] < b[i + 1]:
			for j in range(i, n - 1):
				if k - b[j] >= 0:
					c.append(a.index(b[j]) + 1)
					k = k - b[j]
					a[a.index(b[j])] = 101
	if k > 0:
		if k - b[n - 1] >= 0:
			c.append(a.index(b[n - 1]) + 1)
	print(len(c))
	print(*c)
else:
	print(0)


(n, k) = map(int, input().split())
l = sorted([(x, i + 1) for (i, x) in enumerate(map(int, input().split()))])
s = []
for i in range(n):
	if l[i][0] > k:
		break
	s += [l[i][1]]
	k -= l[i][0]
print(len(s))
print(*s)


def inp():
	return map(int, input().split())

def arr_inp():
	return [[i, int(x)] for (i, x) in enumerate(input().split())]

def print_arr(arr):
	print(*arr, sep=' ')
(n, k) = inp()
a = arr_inp()
a.sort(key=lambda x: x[1])
new_arr = []
for i in range(n):
	if a[i][1] <= k:
		k -= a[i][1]
		new_arr.append(a[i][0] + 1)
	else:
		break
print(len(new_arr))
print_arr(new_arr)


from operator import itemgetter
from collections import OrderedDict
(n, k) = input().split()
(n, k) = (int(n), int(k))
a = list(map(int, input().split()))
ins = {}
sum = 0
cnt = 0
output = ''
for i in range(1, n + 1):
	ins[i] = a[i - 1]
ins = OrderedDict(sorted(ins.items(), key=itemgetter(1)))
for i in ins:
	if sum + ins[i] <= k:
		sum += ins[i]
		cnt += 1
	else:
		break
print(cnt)
for i in ins:
	if cnt > 0:
		output += str(i) + ' '
		cnt -= 1
	else:
		break
print(output)


import operator

def solve(xs, k):
	if k == 0:
		return []
	indexed_xs = list(enumerate(xs, 1))
	indexed_xs.sort(key=operator.itemgetter(1))
	acc = 0
	result = []
	for (i, x) in indexed_xs:
		acc += x
		if acc <= k:
			result.append(i)
		else:
			break
	return sorted(result)

def main():
	[n, k] = [int(i) for i in input().strip().split()]
	xs = [int(i) for i in input().strip().split()]
	assert len(xs) == n
	result = solve(xs, k)
	print(len(result))
	print(' '.join((str(n) for n in result)))
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(1, n + 1):
	b.append(i)
for i in range(n):
	for j in range(n - i - 1):
		if a[j] > a[j + 1]:
			temp = a[j + 1]
			a[j + 1] = a[j]
			a[j] = temp
			temp = b[j + 1]
			b[j + 1] = b[j]
			b[j] = temp
p = 0
s = 0
for i in a:
	if s + i <= k:
		p += 1
		s += i
print(p)
for i in b[:p]:
	print(i, end=' ')


(n, k) = list(map(lambda x: int(x), input().split()))
days = list(map(lambda x: int(x), input().split()))
indices = sorted(range(len(days)), key=lambda x: days[x])
bim = 0
counter = 0
for index in indices:
	if days[index] + bim <= k:
		counter += 1
		bim += days[index]
print(counter)
for x in map(lambda x: x + 1, indices[:counter]):
	print(x, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(1, n + 1):
	l.append((i, a[i - 1]))
l.sort(key=lambda p: p[1])
q = 0
c = 0
while c < n and q <= k:
	q += l[c][1]
	c += 1
	if q > k:
		c -= 1
print(c)
print(' '.join(map(str, [i[0] for i in l[:c]])))


n = list(map(int, input().split()))
n1 = list(map(int, input().split()))
lst = []
lst1 = []
s = 0
for i in n1:
	lst.append(i)
lst.sort()
for j in lst:
	s = s + j
	if s > n[1]:
		break
	lst1.append(n1.index(j) + 1)
	n1.insert(n1.index(j), '')
	n1.remove(n1[n1.index(j)])
if lst1 == []:
	print(0)
else:
	print(len(lst1))
	for k in lst1:
		print(k, end=' ')


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(c[i])
b.sort()
a = []
for i in b:
	if i <= m:
		a.append(c.index(i) + 1)
		c[a[-1] - 1] = 0
		m -= i
	else:
		break
print(len(a))
print(*a)


(n, k) = map(int, input().split())
nums = list(map(int, input().split()))
pairs = []
for i in range(n):
	pairs.append([nums[i], i])
pairs.sort()
indices = []
sm = 0
count = 0
for pair in pairs:
	if sm + pair[0] > k:
		break
	else:
		sm += pair[0]
		count += 1
		indices.append(pair[1])
print(count)
if count != 0:
	[print(x + 1, end=' ') for x in indices]
	print()


(n, k) = [int(x) for x in input().split()]
l = []
ans = []
i = 1
for x in input().split():
	l.append((int(x), i))
	i += 1
l.sort()
counter = 0
while k > 0 and counter < len(l):
	k -= l[counter][0]
	ans.append(l[counter][1])
	counter += 1
if k < 0:
	counter -= 1
	ans.pop()
print(counter)
print(*ans)


(n, k) = [int(x) for x in input().split()]
days = [int(x) for x in input().split()]
daysnew = [[days[x], x + 1] for x in range(n)]
daysnew = sorted(daysnew, key=lambda x: x[0])
time = 0
instruments = []
for i in range(n):
	time = time + daysnew[i][0]
	if time > k:
		i = i - 1
		break
	elif time == k:
		instruments.append(str(daysnew[i][1]))
		break
	else:
		instruments.append(str(daysnew[i][1]))
if i + 1 == 0:
	print(0)
else:
	print(i + 1)
	print(' '.join(instruments))


(n, k) = map(int, input().split())
l = [(int(x), i) for (i, x) in enumerate(input().split())]
l.sort()
days = 0
ans = []
for i in range(len(l)):
	days += l[i][0]
	if days <= k:
		ans.append(str(l[i][1] + 1))
print(len(ans))
if len(ans) > 0:
	print(' '.join(ans))


(n, time) = map(int, input().split())
a = list(map(int, input().split()))
sum_t = 0
index = []
count = 0
if min(a) > time:
	print(0)
else:
	while sum_t < time:
		t_min = min(a)
		if sum_t + t_min <= time:
			sum_t += t_min
			index.append(str(a.index(t_min) + 1))
			a[a.index(t_min)] = 101
			count += 1
		else:
			break
		if count == n:
			break
	print(count)
	print(' '.join(index))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

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

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(nb_inst, nb_days) = read_ints()
day_to_learn = read_ints()
ans = []
for (a, b) in sorted(zip(day_to_learn, range(nb_days))):
	if a <= nb_days:
		ans.append(b + 1)
		nb_days -= a
print(len(ans))
print(*ans)


(a, b) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
y = [(x[i], i + 1) for i in range(a)]
y.sort()
sa = 0
fin = ''
while sa < a:
	if not y[0][0] <= b:
		break
	b -= y[0][0]
	fin += str(y[0][1])
	fin += ' '
	y = y[1:]
	sa += 1
print(sa)
print(fin.strip())


string = input()
numbers = string.split(' ')
instruments = int(numbers[0])
days = int(numbers[1])
string = input()
numbers = string.split(' ')
for x in range(instruments):
	numbers[x] = int(numbers[x])
order = sorted(numbers)
learnt = []
n = 0
i = 0
while n < days and i < instruments:
	x = order[i]
	n += x
	y = 0
	while numbers[y] != x or str(y + 1) in learnt:
		y += 1
	learnt.append(str(y + 1))
	i += 1
if n > days:
	del learnt[i - 1]
	i -= 1
print(i)
print(' '.join(learnt))


(n, k) = input().split()
n = int(n)
k = int(k)
l = input().split()
q = []
for i in range(n):
	l[i] = int(l[i])
	q.append(i + 1)
p = []
m = 0
for i in range(n):
	mini = 101
	for j in range(i, n):
		if mini > l[j]:
			mini = l[j]
			r = j
	(l[i], l[r]) = (l[r], l[i])
	(q[i], q[r]) = (q[r], q[i])
	if k - l[i] >= 0:
		k -= l[i]
		p.append(q[i])
		m += 1
print(m)
for i in range(m):
	print(p[i], '', end='')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
(s, m, l) = (0, 0, [])
while b and s + b[0] <= k:
	x = b.pop(0)
	s += x
	m += 1
	l.append(a.index(x) + 1)
	a[a.index(x)] = ''
print(m)
for i in l:
	print(i, end=' ')


(n, k) = map(int, input().split())
a = [(i, e) for (i, e) in enumerate(map(int, input().split()))]
a.sort(key=lambda x: x[1])
(s, d) = (0, [])
for (i, e) in a:
	if s + e <= k:
		s += e
		d.append(i + 1)
	else:
		break
print(len(d))
for i in d:
	print(i, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
m = 0
c = []
d = []
for i in range(n):
	if k - b[i] >= 0:
		k -= b[i]
		m += 1
		l = d.count(b[i])
		r = a.index(b[i])
		x = 0
		for j in range(r, n):
			if a[j] == b[i]:
				x += 1
			if x == l + 1:
				break
		c.append(j + 1)
		d.append(b[i])
	if k <= 0:
		break
print(m)
print(*c)


(n, k) = map(int, input().split())
s = '\n'
for (j, i) in sorted(((j, i) for (i, j) in enumerate(map(int, input().split()), 1))):
	if j > k:
		break
	k -= j
	s += str(i) + ' '
print(str(s.count(' ')) + s)


(x, y) = [int(x) for x in input().split()]
pi = [int(x) for x in input().split()]
d = dict()
for (i, val) in enumerate(pi):
	x = d.get(val, [])
	x.append(i + 1)
	d[val] = x
pi.sort()
si = 0
sol = []
n = 0
while pi:
	ins = pi.pop(0)
	if ins + si > y:
		break
	elif ins + si <= y:
		si += ins
		sol.append(d[ins].pop())
print(len(sol))
if sol:
	print(' '.join(map(str, sorted(sol))))


(n, k) = map(int, input().split())
a = list(enumerate(list(map(int, input().split()))))
a = sorted(a, key=lambda x: x[1])
res = []
i = 0
s = 0
while i < len(a):
	s += a[i][1]
	if s > k:
		break
	res.append(a[i][0] + 1)
	i += 1
print(len(res))
print(' '.join((str(x) for x in res)))


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = dict()
for (i, e) in enumerate(a):
	d[e] = d.get(e, [])
	d[e].append(i + 1)
s = 0
o = 0
t = ''
for i in sorted(d.keys()):
	for j in d[i]:
		if s + i <= k:
			s += i
			o += 1
			t += str(j) + ' '
print(o)
print(t)


(n, m) = map(int, input().split())
K = list(map(int, input().split()))
l = L = len(K)
k = []
while L:
	L -= 1
	k.append([K[L], L + 1])
k.sort()
s = i = 0
while i < l:
	s += k[i][0]
	if s > m:
		s -= k[i][0]
		break
	i += 1
print(i)
while i:
	i -= 1
	if i:
		print(k[i][1], end=' ')
	else:
		print(k[i][1])


(n, k) = list(map(int, input().split()))
days = [(int(x), cnt) for (cnt, x) in enumerate(input().split())]
days.sort()
ans = []
for (day, inst) in days:
	if day > k:
		break
	else:
		ans.append(str(inst + 1))
		k -= day
print(len(ans))
if ans != []:
	print(' '.join(ans))


(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
for i in range(n):
	l[i] = (l[i], i + 1)
l.sort()
s = 0
ind = 0
while ind < n and s + l[ind][0] <= k:
	s += l[ind][0]
	ind += 1
print(ind)
for i in range(ind):
	print(l[i][1], end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = sorted(l)
ind = 0
while k > 0 and ind < n:
	if k - a[ind] < 0:
		break
	k -= a[ind]
	ind += 1
print(ind)
for i in range(ind):
	i1 = l.index(a[i])
	print(i1 + 1, end=' ')
	l[i1] = -1


(instr, days) = (int(x) for x in input().split())
arr = [(int(y), x + 1) for (x, y) in enumerate(input().split())]
arr.sort()
sum_per = 0
answer = []
for pair in arr:
	sum_per += pair[0]
	if sum_per > days:
		sum_per -= pair[0]
		break
	else:
		answer.append(str(pair[1]))
print(len(answer))
if sum_per != 0:
	print(' '.join(answer))


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(n, k) = mp()
arr = lmp()
arr = sorted([(arr[i], i) for i in range(n)])
x = 0
i = 0
ansl = []
while i < n:
	x += arr[i][0]
	ansl.append(arr[i][1] + 1)
	if x > k:
		ansl.pop()
		break
	i += 1
print(i)
print(*ansl)


get = lambda : list(map(int, input().split()))
(n, k) = get()
l = get()
m = sorted(l)
s = 0
S = []
for i in m:
	if s + i > k:
		break
	s += i
	S.append(i)
print(len(S))
ans = []
for i in S:
	j = l.index(i)
	ans.append(j + 1)
	l[j] = 1000000000
ans = map(str, ans)
print(' '.join(ans))


import sys
(n, k) = map(int, sys.stdin.readline().split())
alist = list(map(int, sys.stdin.readline().split()))
adict = dict()
for (i, a) in enumerate(alist):
	if a in adict:
		adict[a].append(i + 1)
	else:
		adict[a] = [i + 1]
blist = sorted(alist)
s = 0
ans = []
for b in blist:
	s += b
	if s > k:
		break
	ans.append(adict[b].pop())
print(len(ans))
if ans:
	print(' '.join([str(a) for a in ans]))


(n, a) = input().split()
n = int(n)
a = int(a)
d = list(map(int, input().strip().split()))[:n]
aa = sorted(d)
e = 0
y = 0
c = 0
b = []
qq = 0
while e + aa[0] <= a:
	y = aa[0]
	b.append(d.index(y))
	qq = d.index(y)
	d[qq] = -1
	e = e + y
	aa.remove(y)
	c = c + 1
	if len(aa) == 0:
		break
print(c)
for i in range(len(b)):
	print(b[i] + 1, end=' ')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
if a == 1 and b < l[0]:
	print(0)
else:
	for i in range(a):
		l[i] = (l[i], i + 1)
	l.sort()
	f = 0
	z = []
	for (i, j) in l:
		if b - i < 0:
			break
		b -= i
		z.append(j)
	print(len(z))
	print(*z, sep=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append([a[i], i])
a.sort()
b.sort()
cnt = 0
sumi = 0
for i in range(n):
	if sumi + a[i] <= k:
		sumi += a[i]
		cnt += 1
	else:
		break
print(cnt)
for i in range(cnt):
	print(b[i][1] + 1, end=' ')


(n, k) = map(int, input().split())
t = list(map(int, input().split()))
T = sorted(t)
u = 0
h = 0
m = []
for j in range(n):
	if u + T[j] <= k:
		u += T[j]
		c = t.index(T[j])
		m.append(c + 1)
		t[c] = -1
		h += 1
	else:
		break
m.sort()
print(h)
print(*m)


(n, k) = map(int, input().split())
t = [(j, i) for (i, j) in enumerate(map(int, input().split()), 1)]
t.sort()
i = 0
while i < n and k >= t[i][0]:
	k -= t[i][0]
	i += 1
print(i)
for k in range(i):
	print(t[k][1], end=' ')


I = lambda : map(int, input().split())
(n, k) = I()
a = list(I())
r = []
while len(r) < n and min(a) <= k:
	for i in range(len(a)):
		if a[i] == min(a):
			r += [i + 1]
			k -= a[i]
			a[i] = k + 1
			break
print(len(r))
print(' '.join(map(str, r)))


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
y = []
for i in x:
	y.append(i)
(count, i) = (0, 0)
a = []
y.sort()
while i < n and k >= y[i]:
	count += 1
	a.append(x.index(y[i]) + 1)
	x[x.index(y[i])] = 0
	k -= y[i]
	i += 1
print(count)
for i in a:
	print(i, end=' ')


(n, k) = map(int, input().split())
req_days = [int(c) for c in input().split()]
req_days_sorted = sorted(((e, i) for (i, e) in enumerate(req_days, 1)))
acc = 0
ans = []
for (e, i) in req_days_sorted:
	if acc + e <= k:
		acc += e
		ans.append(i)
	else:
		break
print(len(ans))
if len(ans) > 0:
	print(*ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {(a[i], i) for i in range(n)}
b = sorted(d)
s = sum(a)
while s > k and b:
	x = b.pop()
	s -= x[0]
x = len(b)
print(x)
for i in range(x):
	print(b[i][1] + 1, end=' ')


(n, k) = list(map(int, input().split()))
a = sorted(enumerate(list(map(int, input().split()))), key=lambda x: x[1])
res = []
cur = 0
for (idx, val) in a:
	if cur + val <= k:
		cur += val
		res.append(idx + 1)
	else:
		break
print(len(res))
print(*res)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l1 = []
l2 = []
for i in range(n):
	l1.append(tuple((l[i], i + 1)))
l1.sort()
ans = []
for i in range(n):
	if l1[i][0] <= k:
		ans.append(l1[i][1])
		k -= l1[i][0]
ans.sort()
print(len(ans))
for i in range(len(ans)):
	print(ans[i], end=' ')


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if a[i] in d:
			d[a[i]].append(i + 1)
		else:
			d[a[i]] = [i + 1]
	count = 0
	ans = []
	a.sort()
	s = 0
	count = 0
	b = []
	i = 0
	while s + a[i] <= k:
		s += a[i]
		i += 1
		if i == n:
			break
	if i == n:
		count = n
		print(n)
	else:
		print(i)
	for x in range(i):
		print(d[a[x]][0], end=' ')
		d[a[x]].remove(d[a[x]][0])

def __starting_point():
	main()
__starting_point()


class Pair:

	def __init__(self, idx, value):
		self.idx = idx
		self.value = value

	def __lt__(self, other):
		return self.value < other.value

	def __repr__(self):
		return str(self.value) + '[' + str(self.idx) + ']'
(n, k) = map(int, input().split())
d = [int(x) for x in input().split()]
data = []
for i in range(n):
	data.append(Pair(i + 1, d[i]))
data.sort()
sum = 0
x = 0
for x in range(len(data)):
	sum += data[x].value
	if sum > k:
		break
if sum <= k:
	x += 1
print(x)
for i in range(x):
	print(data[i].idx, end=' ')


(n, k) = map(int, input().split())
a = sorted(zip(list(map(int, input().split())), range(1, n + 1)))
d = 0
l = []
for i in a:
	d += i[0]
	if d <= k:
		l.append(i[1])
print(len(l))
print(*l)


R = lambda : map(int, input().split())
(n, k) = R()
s = '\n'
for (j, i) in sorted(zip(R(), range(n))):
	if j <= k:
		k -= j
		s += str(i + 1) + ' '
print(str(s.count(' ')) + s)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
s = 0
ans = []
for i in b:
	if s + i <= k:
		s += i
		ans.append(i)
if len(ans) == 0:
	print(0)
else:
	print(len(ans))
	for i in range(len(ans)):
		print(a.index(ans[i]) + 1, end=' ')
		a[a.index(ans[i])] = -1


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = [a[i], i]
a.sort()
ans = []
cnt = 0
p = 0
while p < n and a[p][0] <= k:
	cnt += 1
	k -= a[p][0]
	ans.append(a[p][1] + 1)
	p += 1
print(cnt)
print(' '.join((str(n) for n in ans)))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
li = l.copy()
li.sort()
ans = []
daysUsed = 0
while len(ans) < n and daysUsed + li[0] <= k:
	daysUsed += li[0]
	ind = l.index(li.pop(0))
	ans.append(ind + 1)
	l[ind] = 0
print(len(ans))
print(*ans)


from collections import deque, defaultdict, Counter
import math
from sys import stdin, stdout

def inp():
	return int(stdin.readline())

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

def insr():
	return list(stdin.readline().strip())

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

def main():
	(n, k) = invr()
	a = inlt()
	d = {}
	for i in range(1, n + 1):
		d[i] = a[i - 1]
	d = {k: v for (k, v) in sorted(d.items(), key=lambda item: item[1])}
	s = 0
	c = 0
	l = []
	for (i, j) in d.items():
		s += j
		if s <= k:
			l.append(i)
			c += 1
	print(c)
	print(*l)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [[a[i], i] for i in range(n)]
b.sort(key=lambda x: x[0])
s = 0
ans = 0
for i in range(n):
	if s + b[i][0] <= k:
		ans += 1
		s += b[i][0]
	else:
		break
print(ans)
for i in range(ans):
	print(b[i][1] + 1, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
l = []
li = []
for z in range(n):
	li.append(z)
(a, li) = zip(*sorted(zip(a, li)))
for z in range(n):
	if k >= a[z]:
		l.append(z)
		k -= a[z]
print(len(l))
for z in l:
	print(li[z] + 1, end=' ')


(n1, k1) = [int(x) for x in input().split()]
s1 = input().split()
l1 = []
for j in range(n1):
	l1.append((int(s1[j]), j + 1))
l1.sort(key=lambda x: x[0])
left1 = 0
right1 = 0
summ1 = 0
flag1 = 0
ans1 = []
elem1 = 0
while left1 <= right1 and right1 < n1:
	while summ1 <= k1:
		summ1 += l1[right1][0]
		if summ1 <= k1:
			ans1.append(l1[right1][1])
			elem1 += 1
			flag1 = 1
		right1 += 1
		if right1 >= n1:
			break
	break
print(elem1)
if flag1 == 1:
	for i in sorted(ans1):
		print(i, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
pos = []
for i in range(n):
	pos.append(i + 1)
x = list(sorted(zip(a, pos)))
a = [i for (i, j) in x]
b = [j for (i, j) in x]
pos = []
for i in range(n):
	s += a[i]
	if s > k:
		break
	pos.append(b[i])
print(len(pos))
pos.sort()
for i in pos:
	print(i, end=' ')


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
T = [[L[k], k + 1] for k in range(n)]

def kt(a):
	return a[0]
T.sort(key=kt)
r = 0
t = 0
while t <= k and r < n:
	t += T[r][0]
	r += 1
print(r - (t > k))
for k in range(r - (t > k)):
	print(T[k][1], end=' ')


(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
_list = [tup for tup in zip(range(1, n + 1), arr)]
_list.sort(key=lambda tup: tup[1])
cnt = 0
_sum = 0
for tup in _list:
	_sum += tup[1]
	if _sum > k:
		break
	cnt = cnt + 1
print(str(cnt))
ans = ''
if cnt > 0:
	for i in range(cnt):
		ans = ans + (str(_list[i][0]) + ' ')
	print(ans)


(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
arr2 = []
for i in range(n):
	arr2.append((arr[i], i))
arr2.sort()
ans = []
for i in arr2:
	if k >= i[0]:
		k -= i[0]
		ans.append(i[1])
print(len(ans))
for i in ans:
	print(i + 1, end=' ')


(n, k) = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
q = sorted(enumerate(q), key=lambda x: x[1])
ans = []
tot = 0
for (idx, item) in q:
	if tot + item <= k:
		tot += item
		ans.append(idx + 1)
	else:
		break
print(len(ans))
if len(ans):
	print(' '.join(map(str, ans)))


nk = input()
(n, k) = [int(i) for i in nk.split(' ')]
a = input()
a = [int(i) for i in a.split(' ')]
b = []
for i in range(len(a)):
	b += [(i, a[i])]
b.sort(key=lambda x: x[1])
m = 0
no = 0
p = []
for i in range(n):
	m += b[i][1]
	if m <= k:
		no += 1
		p.append(b[i][0])
	else:
		break
if len(p) > 0:
	print(no)
	for i in p:
		print(i + 1, end=' ')
else:
	print(0)


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a = [[a[i], i + 1] for i in range(len(a))]
a.sort(key=lambda x: x[0])
res = []
for i in range(len(a)):
	if k < a[i][0]:
		break
	res.append(a[i][1])
	k -= a[i][0]
print(len(res))
if len(res) > 0:
	res = [str(i) for i in res]
	print(' '.join(res))


(n, k) = (int(x) for x in input().split())
arr = sorted([(int(x), i) for (i, x) in enumerate(input().split())])
ans = 0
for v in arr:
	if k - v[0] >= 0:
		ans += 1
		k -= v[0]
	else:
		break
print(ans)
print(' '.join((str(v[1] + 1) for v in arr[:ans])))


(n, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
temp = arr.copy()
temp.sort()
ans = []
total = 0
for x in range(n):
	total += temp[x]
	if total <= k:
		ans.append(arr.index(temp[x]))
		arr[arr.index(temp[x])] = 10000
print(len(ans))
for x in ans:
	print(x + 1, end=' ')


import sys
from itertools import groupby
sys.setrecursionlimit(1000000000)
lines = []
for Line in sys.stdin:
	lines.append(Line.rstrip('\n'))
(n, k) = list(map(int, lines[0].split()))
del lines[0]
A = list(map(int, lines[0].split()))
del lines[0]
B = []
for i in range(len(A)):
	B += [(A[i], i)]
A = sorted(B)
T = 0
s = 0
I = []
while T <= k and s < n:
	T += A[s][0]
	if T <= k:
		I += [A[s][1] + 1]
		s += 1
print(len(I))
if len(I) > 0:
	I = sorted(I)
	print(*I)


(n, k) = map(int, input().split())
v = list()
(tot, c) = (0, 0)
l = list(map(int, input().split()))
ls = l
ls = sorted(ls)
for i in ls:
	if i + tot <= k:
		tot += i
		c += 1
		v.append(l.index(i))
		l[l.index(i)] = -1
	else:
		break
print(c)
for j in v:
	print(j + 1, end=' ')


__author__ = 'Hippskill'

def main():
	rdl = list(map(int, input().split()))
	rdl1 = list(map(int, input().split()))
	kl = 0
	need = []
	while rdl[1] > 0:
		current = find_min(rdl1)
		if rdl[1] - rdl1[current] >= 0:
			kl += 1
			need.append(current + 1)
			rdl[1] -= rdl1[current]
		else:
			break
		rdl1[current] = 10000000
	print(kl)
	for i in need:
		if i != need[len(need) - 1]:
			print(i, end=' ')
		else:
			print(i, end='')

def find_min(vect):
	mins = 10000000000
	toOut = 0
	for i in range(len(vect)):
		if mins > vect[i]:
			mins = vect[i]
			toOut = i
	return toOut
main()


a = 0
lst = []
z = list(map(int, input().split()))
f = list(map(int, input().split()))
x = sorted(f.copy())
for i in range(z[0]):
	a += x[i]
	if a <= z[1]:
		lst.append(x[i])
	else:
		break
print(len(lst))
for i in lst:
	if f.count(i) == 1:
		print(f.index(i) + 1, end=' ')
	else:
		print(f.index(i) + 1, end=' ')
		f[f.index(i)] = -1


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
sorted_arr = sorted(arr)
music = []
dic = {}
for i in range(len(arr)):
	dic[i + 1] = arr[i]

def indexOf(dic, val):
	for key in dic.keys():
		if dic[key] == val:
			del dic[key]
			return key
days_left = k
cnt = 0
music = []
for i in range(len(sorted_arr)):
	if sorted_arr[i] <= days_left:
		music.append(indexOf(dic, sorted_arr[i]))
		cnt += 1
		days_left = days_left - sorted_arr[i]
print(cnt)
for item in music:
	print(item, end=' ')


(n, k) = map(int, input().split())
k_1 = list(map(int, input().split()))
(m, h) = ([], [])
(j, summ) = (0, 0)
for i in k_1:
	j += 1
	m.append([i, j])
m.sort()
for i in m:
	if summ + i[0] <= k:
		summ += i[0]
		h.append(i[1])
if len(h) == 0:
	print(0)
else:
	print(len(h))
	for i in h:
		print(i, end=' ')


(n, d) = map(int, input().split())
arr = list(map(int, input().split()))
arr2 = arr[0:len(arr) + 1]
arr2.sort()
vec = []
for i in arr2:
	if d - i >= 0:
		pos = arr.index(i)
		vec.append(pos + 1)
		arr[pos] = -1
		d -= i
	else:
		break
print(len(vec))
vec = list(map(str, vec))
print(' '.join(vec))


def checkk(x, i, s, k):
	global j
	for j in range(len(x), 0, -1):
		if i * j + s <= k:
			return True
	return False
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
dic = {}
j = 0
for i in range(n):
	if arr[i] not in dic:
		dic[arr[i]] = [i + 1]
	else:
		dic[arr[i]] += [i + 1]
summ = 0
lstn = []
for i in range(1, 101):
	if i in dic:
		if checkk(dic[i], i, summ, k):
			summ += i * j
			lstn.extend(dic[i][:j])
print(len(lstn))
print(*lstn)


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
x = ai.copy()
x.sort(reverse=True)
summ = 0
cnt = 0
lst = []
if sum(ai) <= k:
	print(len(ai))
	print(*range(1, len(ai) + 1))
else:
	while k > summ:
		summ += x[-1]
		if summ > k:
			break
		lst.append(x[-1])
		x.pop(-1)
		cnt += 1
	print(cnt)
	ind = []
	for i in range(len(ai)):
		ind.append([ai[i], i + 1])
	dic = []
	for i in range(len(ai)):
		dic.append([ai[i], i + 1])
	dic.sort()
	flag = 0
	for i in dic:
		if flag >= cnt:
			break
		print(i[1], end=' ')
		flag += 1


(n, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = l1.copy()
l2.sort()
l3 = []
while len(l2) > 0:
	if k < l2[0]:
		break
	elif k >= l2[0]:
		k -= l2[0]
		l3.append(l1.index(l2[0]) + 1)
		l1[l1.index(l2[0])] = 0
		l2.pop(0)
if len(l3) > 0:
	print(len(l3))
	for i in range(len(l3)):
		print(l3[i], end=' ')
else:
	print(0)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
if k >= sum(l):
	l = [i for i in range(1, n + 1)]
	print(n)
	print(*l)
else:
	temp = l.copy()
	temp.sort()
	test = []
	ans = []
	i = 0
	while sum(test) < k and i < len(l):
		x = l.index(temp[i])
		test.append(temp[i])
		if sum(test) <= k:
			ans.append(x + 1)
		l[x] = 0
		i = i + 1
	print(len(ans))
	if len(ans) != 0:
		print(*ans)


from collections import namedtuple
Pair = namedtuple('Pair', ['first', 'second'])
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
p = []
for i in range(n):
	p.append(Pair(a[i], i + 1))
p.sort(key=lambda element: (element.first, element.second))
ans = []
c = 0
i = 0
while k > 0 and i < n:
	if k - p[i].first < 0:
		break
	ans.append(p[i].second)
	k -= p[i].first
	i += 1
	c += 1
print(c)
for item in sorted(ans):
	print(item, end=' ')


import copy
(n, k) = [int(x) for x in input().split()]
line = [int(x) for x in input().split()]
days = [(line[i], i + 1) for i in range(n)]
days.sort(key=lambda x: x[0])
ans = 0
ansl = []
for i in range(n):
	if days[i][0] <= k:
		ans += 1
		ansl.append(days[i][1])
		k -= days[i][0]
	if k <= 0:
		break
print(ans)
print(' '.join([str(x) for x in ansl]))


(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
brr = [int(i) for i in arr]
arr.sort()
c = 0
while c <= n and k - sum(arr[:c]) >= 0:
	c = c + 1
print(len(arr[:c - 1]))
x = 0
for i in range(n):
	if brr[i] not in arr[:c - 1]:
		brr[i] = -1
	else:
		print(brr.index(brr[i]) + 1, end=' ')
		brr[i] = -1
		x = x + 1
	if x == len(arr[:c - 1]):
		break


(n, k) = map(int, input().split())
z = [int(x) for x in input().split()]
old = z
z = sorted(range(len(z)), key=lambda k: z[k])
total = 0
index = 0
for i in range(n):
	if total + int(old[z[i]]) <= k:
		total = total + int(old[z[i]])
		index += 1
print(index)
if index != 0:
	print(' '.join((str(x + 1) for x in z[0:index])))


a = int(input().split()[1])
b = list(map(int, input().split()))
c = {}
for i in range(len(b)):
	c[i + 1] = b[i]
d = []
for i in sorted(c.keys(), key=lambda x: c[x]):
	if c[i] > a:
		break
	d += [i]
	a -= c[i]
print(len(d))
if d:
	print(' '.join(map(str, sorted(d))))


(n, days) = map(int, input().split())
arr = list(map(int, input().split()))
key = list(range(1, n + 1))
dict1 = dict(zip(key, arr))
sorted_tuples = sorted(dict1.items(), key=lambda item: item[1])
sorted_dict = {k: v for (k, v) in sorted_tuples}
tot = 0
ans = list()
for (k, v) in sorted_dict.items():
	if days - v >= 0:
		days -= v
		ans.append(k)
		tot += 1
	else:
		break
print(tot)
if ans:
	print(' '.join((str(i) for i in ans)))


def _2_Heap_Sort(Seq, Seq_2):
	_2_Heaping(Seq, Seq_2)
	Height = len(Seq) - 1
	for I in range(Height, -1, -1):
		(Seq[0], Seq[I]) = (Seq[I], Seq[0])
		(Seq_2[0], Seq_2[I]) = (Seq_2[I], Seq_2[0])
		Height = Height - 1
		_2_Find_Max(Seq, Seq_2, Height)
	return Seq_2

def _2_Find_Max(Seq, Seq_2, N, I=0):
	Left_Bound = I + 1
	Right_Bound = I + 2
	if Left_Bound <= N and Seq[Left_Bound] > Seq[I]:
		Largest = Left_Bound
	else:
		Largest = I
	if Right_Bound <= N and Seq[Right_Bound] > Seq[Largest]:
		Largest = Right_Bound
	if not Largest == I:
		(Seq[I], Seq[Largest]) = (Seq[Largest], Seq[I])
		(Seq_2[I], Seq_2[Largest]) = (Seq_2[Largest], Seq_2[I])
		_2_Find_Max(Seq, Seq_2, N, Largest)

def _2_Heaping(Seq, Seq_2):
	N = len(Seq) - 1
	for I in range(N, -1, -1):
		_2_Find_Max(Seq, Seq_2, N, I)
from sys import stdin, stdout
input = stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ind = _2_Heap_Sort(a, list(range(1, n + 1)))
ans = 0
s = 0
while s < k and ans < n:
	if s + a[ans] <= k:
		s += a[ans]
		ans += 1
	else:
		break
stdout.write(str(ans) + '\n')
stdout.write(' '.join(map(str, ind[:ans])))


from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
(n, k) = M()
a = LI()
b = sorted(a)
c = []
for i in range(n):
	if b[i] <= k:
		d = a.index(b[i])
		a[d] = -1
		c.append(d + 1)
		k -= b[i]
print(len(c))
print(*c)


(N, K) = list(map(int, input().split()))
s = list(sorted([(int(n), i) for (i, n) in enumerate(input().split())]))
ans = []
n = 0
for (c, i) in s:
	if n + c > K:
		break
	ans.append(i + 1)
	n += c
print(len(ans))
if ans:
	print(' '.join(map(str, ans)))


def quick_sort(array):
	left = []
	equal = []
	right = []
	if len(array) > 1:
		pivot = array[0][1]
		for x in range(len(array)):
			if array[x][1] < pivot:
				left.append(array[x])
			elif array[x][1] == pivot:
				equal.append(array[x])
			elif array[x][1] > pivot:
				right.append(array[x])
		return quick_sort(left) + equal + quick_sort(right)
	else:
		return array

def learn_instruments():
	time = list(map(int, input().split()))
	instruments = list(map(int, input().split()))
	output = 0
	output_str = ''
	values = []
	for i in range(len(instruments)):
		values.append([i + 1])
		values[i].append(instruments[i])
	values = quick_sort(values)
	for i in range(len(values)):
		if time[1] <= 0 or time[1] - values[i][1] < 0:
			break
		time[1] -= values[i][1]
		output += 1
		output_str = output_str + str(values[i][0]) + ' '
	if output == 0:
		print(output)
	else:
		print(output)
		print(output_str)
learn_instruments()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, ind, c) = ([], [], 0)
for i in range(n):
	ind.append(i + 1)
for i in range(1, n, 1):
	for j in range(0, n - i, 1):
		if a[j] > a[j + 1]:
			(a[j], a[j + 1]) = (a[j + 1], a[j])
			(ind[j], ind[j + 1]) = (ind[j + 1], ind[j])
for i in range(n):
	if k <= 0 or k < a[i]:
		break
	else:
		l.append(ind[i])
		c += 1
		k -= a[i]
print(c)
print(*l, end=' ')


(a, b) = map(int, input().split())
x = [int(x) for x in input().split()]
y = x[:]
y = sorted(y)
s = 0
t = [0] * a
for i in range(len(y)):
	if s + y[i] <= b:
		s += y[i]
		t[i] = x.index(y[i]) + 1
		x[t[i] - 1] = 0
z = []
for i in range(len(x)):
	if x[i] == 0:
		z.append(i + 1)
print(x.count(0))
print(*z)


__author__ = 'myduomilia'

def sortInstrument(instrument):
	return instrument.time

class Instrument:

	def __init__(self, ind, tim):
		self.ind = ind + 1
		self.time = tim
(n, time) = list(map(int, input().split()))
arr = list(map(int, input().split()))
ans = 0
t = 0
instruments = []
for (i, val) in enumerate(arr):
	instruments.append(Instrument(i, val))
instruments.sort(key=sortInstrument)
a = []
for val in instruments:
	if t + val.time <= time:
		a.append(val.ind)
		ans += 1
		t += val.time
print(ans)
print(' '.join((str(val) for val in a)))


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
sum = 0
count = 0
instruments = ''
while sum + min(a) <= k:
	sum += min(a)
	count += 1
	instruments += '%s ' % str(a.index(min(a)) + 1)
	a[a.index(min(a))] = 999999
print(count)
if count > 0:
	print(instruments)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted([(a[i], i) for i in range(len(a))])
(l, s) = (0, 0)
while l < n and s + b[l][0] <= k:
	s += b[l][0]
	l += 1
print(l)
if l > 0:
	print(' '.join([str(b[i][1] + 1) for i in range(l)]))


(m, k) = map(int, input().split())
a = list(map(int, input().split()))
an = [[a[i], i + 1] for i in range(len(a))]
an = sorted(an)
kn = 0
ans = []
for i in range(len(an)):
	if kn + an[i][0] > k:
		break
	kn += an[i][0]
	ans.append(an[i][1])
print(len(ans))
for i in ans:
	print(i, end=' ')
print()


(n, k) = [int(i) for i in input().split()]
a = [(int(v), i) for (i, v) in enumerate(input().split())]
a.sort()
result = []
for (v, i) in a:
	k -= v
	if k < 0:
		break
	result.append(i + 1)
result.sort()
print(len(result))
print(' '.join((str(i) for i in result)))


s = [int(i) for i in input().split(' ')]
n = s[0]
k = s[1]
a = [int(i) for i in input().split(' ')]
a_1 = sorted(a)
m = 0
instr = []
while k >= 0 and m < n:
	k -= a_1[m]
	if k < 0:
		break
	instr.append(str(a.index(a_1[m]) + 1))
	a[a.index(a_1[m])] = 101
	m += 1
print(m)
if m != 0:
	print(' '.join(instr))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l2 = l.copy()
l2.sort()
l1 = []
while len(l2) > 0:
	if l2[0] > k:
		break
	else:
		k -= l2[0]
		l1.append(l.index(l2[0]) + 1)
		l[l.index(l2[0])] = 0
		l2.remove(l2[0])
		if k < 0:
			l1.remove(l1[-1])
			break
print(len(l1))
print(' '.join(map(str, l1)))


(numbers_length, size) = input().split(' ')
numbers_length = int(numbers_length)
size = int(size)
numbers = input().split(' ')
numbers = list(map(int, numbers))
total = 0
last_index = 0
result = []
for (a, b) in sorted(zip(numbers, range(1, size + 1))):
	if total + a > size:
		break
	total += a
	last_index += 1
	result.append(b)
print(len(result))
print(' '.join(map(str, result)))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
t = sorted(l)
s = 0
a = 0
p = []
for i in range(n):
	s += t[i]
	if s <= k:
		a += 1
	else:
		break
print(a)
for j in range(a):
	r = l.index(t[j])
	print(r + 1, end=' ')
	l[r] = -1


(n, k) = map(int, input().split())
l = [int(n) for n in input().split()]
for i in range(n):
	l[i] = [int(l[i]), i]
ls = sorted(l)
s = i = c = 0
for i in range(n):
	s = s + ls[i][0]
	if s <= k:
		c += 1
print(c)
if c > 0:
	for i in range(c):
		print(int(ls[i][1]) + 1, end=' ')


(n, k) = input().split()
a = [int(i) for i in input().split()]
n = int(n)
k = int(k)
for i in range(len(a)):
	a[i] = (a[i], i + 1)
a = sorted(a)
ans = []
total = 0
for i in range(len(a)):
	if total + a[i][0] > k:
		break
	total = total + a[i][0]
	ans.append(a[i][1])
ans = sorted(ans)
print(len(ans))
for i in ans:
	print(i, end=' ')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l1 = sorted(l)
total = 0
z = []
for x in l1:
	if total + x <= b:
		total += x
		z.append(l.index(x) + 1)
		l[l.index(x)] = -1
	else:
		break
print(len(z), '\n', *z)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ans = []
sum1 = 0
for i in range(len(l)):
	ans.append((i, l[i]))
ans.sort(key=lambda x: x[1])
t = []
for i in range(len(l)):
	sum1 = sum1 + ans[i][1]
	if sum1 > k:
		break
	t.append(ans[i][0] + 1)
print(len(t))
print(*t)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = []
for i in range(n):
	b.append((a[i], i))
b.sort()
cnt = 0
ans = []
for i in range(n):
	k -= b[i][0]
	if k < 0:
		break
	cnt += 1
	ans.append(b[i][1] + 1)
print(cnt)
if cnt > 0:
	print(' '.join([str(x) for x in ans]))


import random
(n, k) = input().split()
a = input().split()
a_1 = list(map(int, a))

def quicksort(nums):
	if len(nums) <= 1:
		return nums
	else:
		q = random.choice(nums)
	l_nums = [n for n in nums if n < q]
	e_nums = [q] * nums.count(q)
	b_nums = [n for n in nums if n > q]
	return quicksort(l_nums) + e_nums + quicksort(b_nums)
num = quicksort(a_1)
num_1 = list(map(int, num))

def check(arr, k):
	T = True
	while T:
		Sum = 0
		for a in arr:
			Sum += int(a)
		if Sum <= int(k):
			T = False
			return len(arr)
		else:
			arr.pop(len(arr) - 1)
m = check(num, k)
res = []
for i in range(1, m + 1):
	ind = a_1.index(num_1[i - 1])
	a_1[ind] = 'wow'
	res.append(ind + 1)
print(m)
s = ' '.join([str(elem) for elem in res])
print(s)


from math import *
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append([a[i], i + 1])
b.sort()
res = []
for i in range(n):
	if b[i][0] <= k:
		k -= b[i][0]
		res.append(b[i][1])
print(len(res))
print(' '.join(map(str, res)))


(n, k) = map(int, input().split())
ins = list(map(int, input().split()))
index = list(range(n))
index.sort(key=lambda x: ins[x])
days = 0
i = 0
ans = []
while True:
	if i >= n:
		break
	days += ins[index[i]]
	if days > k:
		break
	else:
		ans.append(index[i] + 1)
	i += 1
print(i)
if i != 0:
	print(' '.join(map(str, ans)))


(ins, day) = map(int, input().split())
lis = list(map(int, input().split()))
ins2 = lis[:]
ins2.sort()
res = 0
reslist = []
while res < ins and day >= ins2[res]:
	a = lis.index(ins2[res])
	lis[a] = -1
	reslist.append(a % ins + 1)
	day -= ins2[res]
	res += 1
print(res)
print(' '.join(map(str, reslist)))


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, K) = map(int, input().split())
A = [int(x) for x in input().split()]
A = [(v, i + 1) for (i, v) in enumerate(A)]
A.sort()
total = 0
i = 0
while i < N and total <= K:
	total += A[i][0]
	i += 1
if total > K:
	print(i - 1)
	print(' '.join(map(str, [x[1] for x in A[:i - 1]])))
else:
	print(i)
	print(' '.join(map(str, [x[1] for x in A[:i]])))


a = input().split()
n = int(a[0])
days = int(a[1])
m = 0
b = []
p = []
copy = []
l = input().split()
for i in range(len(l)):
	p.append(int(l[i]))
	copy.append(int(l[i]))
total = sum(p)
temp = 45
s = ''
lota = []
e = [1 for i in range(n)]
temp = []
if min(p) > days:
	print(0)
else:
	while True:
		if len(p) > 0 and min(p) - days <= 0:
			now = min(p)
			days = days - now
			p.remove(now)
			t = copy.index(now)
			copy[t] = 1011
			s = s + str(t + 1) + ' '
			if days == 0:
				break
		else:
			days = days + now
			for i in range(days, now + 1, -1):
				if i in copy:
					now = copy[i]
					t = copy.index(i)
					s = s + str(t + 1)
					temp = 0
				break
			break
	if temp != 0:
		h = s.split()
		print(len(h))
		print(s)
	else:
		h = s.split()
		print(len(h) - 1)
		r = len(h)
		s = ''
		for i in range(-1, -r - 1, -1):
			if i != -2:
				s = h[i] + ' ' + s
		print(s)


def main():
	(n, k) = read()
	a = read()
	b = []
	for i in range(n):
		b.append((a[i], i + 1))
	b.sort()
	c = 0
	res = []
	while c < n:
		if k >= b[c][0]:
			res.append(b[c][1])
			k -= b[c][0]
			c += 1
		else:
			break
	print(len(res))
	write(res)

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


(MyDict, Answer, i, Sum, X, Days) = ({}, [], 0, 0, list(map(int, input().split())), list(map(int, input().split())))
for i in range(X[0]):
	MyDict[i + 1] = Days[i]
MyDict = dict(sorted(MyDict.items(), key=lambda key: key[1]))
for i in range(len(MyDict.values())):
	if Sum + list(MyDict.values())[i] <= X[1]:
		Sum += list(MyDict.values())[i]
		Answer.append(list(MyDict.keys())[i])
	else:
		break
print(len(Answer))
print(*Answer)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(1, n + 1)]
z = zip(a, b)
b = [x for (_, x) in sorted(z)]
a.sort()
total = 0
count = 0
temp = []
for i in range(n):
	total += a[i]
	if total <= k:
		count += 1
		temp.append(b[i])
	else:
		break
print(count)
for x in temp:
	print(x, end=' ')


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
out = []
while k > 0:
	z = min(arr)
	if z == 101:
		break
	else:
		i = arr.index(z)
		if z <= k:
			k -= z
			out.append(i + 1)
			arr[i] = 101
		else:
			k = 0
print(len(out))
if len(out) > 0:
	print(' '.join([str(i) for i in out]))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = a[:]
a.sort()
(x, c) = (0, 0)
for i in range(n):
	x += a[i]
	if x < k:
		c += 1
	else:
		if k - x >= 0:
			c = c + 1
		break
print(c)
for i in range(c):
	x = l.index(a[i])
	print(x + 1, end=' ')
	l[x] = -1


(n, k) = map(int, input().split())
l = [(int(i), j) for (j, i) in enumerate(input().split())]
ans = []
l.sort()
for (val, ind) in l:
	if k - val >= 0:
		k -= val
		ans.append(ind + 1)
	else:
		break
print(len(ans))
for i in ans:
	print(i, end=' ')


(n, k) = map(int, input().split())
a = [int(z) for z in input().split()]
u = k
oo = []
for i in a:
	d = a.index(min(a))
	if u < a[d]:
		break
	else:
		u -= a[d]
		oo += [d + 1]
		a[d] = k
print(len(oo))
if oo:
	print(*oo, sep=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = ''
t = 0
m = 0
c = 0
p = 0
for i in range(n):
	m = min(a)
	t = a.index(m)
	a[t] = 101
	c += m
	if c > k:
		break
	p += 1
	s += str(t + 1) + ' '
print(p)
print(s)


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
	A[i] = [A[i], i]
A.sort()
ans = []
for j in range(n):
	if k >= A[j][0]:
		k -= A[j][0]
		ans.append(A[j][1] + 1)
print(len(ans))
print(*ans)


(n, k) = list(map(int, input().rstrip().split()))
a = list(map(int, input().rstrip().split()))
b = a.copy()
a.sort()
t = 0
ind = []
count = 0
for x in a:
	if t + x <= k:
		t += x
		count += 1
		for i in range(n):
			if b[i] == x:
				ind += [i + 1]
				b[i] = -1
				break
	else:
		break
print(count)
if count > 0:
	print(*ind)


(n, k) = (int(X) for X in input().split())
L = [[int(X)] for X in input().split()]
L[0] += [1]
for i in range(1, n):
	L[i] += [L[i - 1][1] + 1]
L.sort()
a = 0
point = 0
for i in range(n):
	if i == n - 1 and a + L[i][0] <= k:
		point = i
	elif a + L[i][0] < k:
		a += L[i][0]
	elif a + L[i][0] == k:
		point = i
		break
	else:
		point = i - 1
		break
print(point + 1)
for i in range(point + 1):
	print(L[i][1], end=' ')


(n, a) = input().split()
n = int(n)
a = int(a)
g = list(map(int, input().strip().split()))[:n]
aaa = sorted(g)
x = 0
y = 0
c = 0
b = []
qq = 0
while x + aaa[0] <= a:
	y = aaa[0]
	b.append(g.index(y))
	qq = g.index(y)
	g[qq] = -1
	x = x + y
	aaa.remove(y)
	c = c + 1
	if len(aaa) == 0:
		break
print(c)
for i in range(len(b)):
	print(b[i] + 1, end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
(d, t, c) = ([], 0, 0)
j = sorted(l)
for i in j:
	if i + t <= k:
		t += i
		c += 1
		d.append(l.index(i))
		l[l.index(i)] = -1
	else:
		break
print(c)
for x in d:
	print(x + 1, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
if sum(b) <= k:
	print(len(a))
	for i in range(len(a)):
		print(i + 1, end=' ')
elif b[0] > k:
	print(0)
else:
	c = []
	p = 0
	d = []
	for i in range(len(b)):
		if p + b[i] <= k:
			for j in range(len(a)):
				if a[j] == b[i] and (not j in d):
					c.append(j + 1)
					p += b[i]
					d.append(j)
					break
		else:
			break
	print(len(c))
	print(*c)


s = input().split()
a = int(s[0])
b = int(s[1])
pat = []
mat = input().split()
for i in range(a):
	mat[i] = int(mat[i])
sat = sorted(mat)
for i in range(a):
	b -= sat[i]
	if b < 0:
		break
	else:
		pat.append(mat.index(sat[i]) + 1)
		mat[mat.index(sat[i])] = int(99999999999999)
print(len(pat))
for i in pat:
	print(i, end=' ')


(n, k) = [int(i) for i in input().split()]
temp = [int(i) for i in input().split()]
li = {}
for i in range(n):
	if temp[i] in li.keys():
		li[temp[i]].append(i)
	else:
		li[temp[i]] = [i]
cnt = 0
ans = []
for i in sorted(li.keys()):
	t = min(k // i, len(li[i]))
	k -= i * t
	cnt += t
	ans += li[i][:t]
print(cnt)
print(' '.join([str(i + 1) for i in ans]))


(m, k) = map(int, input().split())
l = list(map(int, input().split()))
z = []
for i in sorted(l[:]):
	if k >= i:
		k -= i
		z.append(i)
res = []
r = {i: z.count(i) for i in set(z)}
for i in set(z):
	if r[i] > 1:
		st = 0
		for j in range(r[i]):
			st += l[st:].index(i) + 1
			res.append(str(st))
	else:
		res.append(str(l.index(i) + 1))
print(0 if len(z) == 0 else str(len(z)) + '\n' + ' '.join(res))


(n, k) = map(int, input().split())
data = [int(i) for i in input().split()]
results = []
t = 0
while len(results) < n and t < k:
	i = data.index(min(data))
	t += data[i]
	results.append(i + 1)
	data[i] = 101
if t > k:
	results = results[:-1]
print(len(results))
if len(results) > 0:
	print(' '.join((str(s) for s in results)))


n1 = input().split()
n = int(n1[0])
m = int(n1[1])
l = list(map(int, input().split()))
S = []
l1 = sorted(l)
k = 0
for i in range(n):
	if m - l1[i] >= 0:
		m = m - l1[i]
		for j in range(n):
			if l1[i] == l[j]:
				S.append(str(j + 1))
				l[j] = 0
				break
		k = k + 1
	else:
		break
print(k)
print(' '.join(S))


(n, k) = map(int, input().split())
M = list(map(int, input().split()))
for i in range(n):
	M[i] = (M[i], i + 1)
M.sort()
if M[0][0] > k:
	print(0)
else:
	used = 0
	i = 0
	Ans = []
	while i < n and used + M[i][0] <= k:
		Ans.append(M[i][1])
		used += M[i][0]
		i += 1
	print(len(Ans))
	print(' '.join(map(str, Ans)))


raw = input()
raw = raw.split(' ')
raw = [int(x) for x in raw]
raw2 = input()
raw2 = raw2.split(' ')
raw2 = [int(x) for x in raw2]
sor = sorted(raw2)
s = 0
ins = []
for x in sor:
	s = s + x
	if s > raw[1]:
		break
	if s <= raw[1]:
		ins.append(raw2.index(x) + 1)
		raw2[raw2.index(x)] = None
print(len(ins))
ins = [str(x) for x in ins]
print(' '.join(ins))


(n, k) = map(int, input().split())
a = [(j, i) for (i, j) in enumerate(map(int, input().split()), 1)]
a.sort()
ans = []
for w in range(0, n):
	if k - a[w][0] < 0:
		break
	else:
		ans = ans + [a[w][1]]
		k = k - a[w][0]
ans = sorted(ans)
print(len(ans))
print(' '.join((str(w) for w in ans)))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
b = list(zip(a, list(range(1, n + 1))))
b.sort()
l = []
g = 0
while t >= 0 and g != n:
	t -= b[g][0]
	l.append(b[g][1])
	g += 1
if t < 0:
	l.pop(-1)
print(len(l))
print(' '.join([str(elem) for elem in l]))


R = lambda : map(int, input().split())
(n, k) = R()
l = sorted(zip(R(), range(1, n + 1)))
h = []
for (_, i) in l:
	k -= _
	if k >= 0:
		h.append(i)
print(len(h))
print(*h)


line = input().split()
n = int(line[0])
k = int(line[1])
line = input().split()
lst = list()
for i in range(1, n + 1):
	lst.append((int(line[i - 1]), i))
lst.sort()
s = 0
c = 0
i = 0
ans = ''
while s < k and i < n:
	if s + lst[i][0] <= k:
		ans = ans + str(lst[i][1]) + ' '
		s += lst[i][0]
		c += 1
	else:
		break
	i += 1
print(str(c))
if c > 0:
	print(ans)


inp = input().split()
(n, k) = (int(inp[0]), int(inp[1]))
inp = input().split()
a = [[int(i)] for i in inp]
for i in range(0, n):
	a[i].append(i + 1)
a.sort()
num = 0
for (i, j) in a:
	if k < i:
		break
	else:
		k -= i
		num += 1
print(num)
if num > 0:
	for i in range(0, num):
		print(a[i][1], end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = sorted(l)
s = 0
a = []
c = 0
for i in range(n):
	if p[i] + s <= k:
		s = s + p[i]
		c = c + 1
		z = l.index(p[i])
		a.append(z + 1)
		l[z] = 0
print(c)
print(*a)


s = list(map(int, input().split()))
l = list(map(int, input().split()))
s1 = sorted(l)
su = 0
idx = {}
for i in range(len(l)):
	try:
		idx[l[i]].append(i)
	except:
		idx[l[i]] = [i]
x = []
for i in s1:
	su += i
	if su <= s[1]:
		x.append(idx[i][0] + 1)
		idx[i].pop(0)
print(len(x))
if len(x) != 0:
	print(*x, sep=' ')


(a, k) = map(int, input().split())
ls = list(map(int, input().split()))
nls = []
for i in ls:
	nls.append(i)
ls.sort()
ind = []
ins = 0
for i in range(a):
	if ls[i] <= k and ins <= k:
		if ins + ls[i] > k:
			break
		else:
			ins += ls[i]
			ind.append(nls.index(ls[i]) + 1)
			nls[nls.index(ls[i])] = 'l'
print(len(ind))
for i in sorted(ind):
	print(i, end=' ')


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

class Instrument:

	def __init__(self, time, position):
		self.time = time
		self.position = position

	def __getTime__(self):
		return self.time

	def __getPosition__(self):
		return self.position
l = [Instrument(a[i], i + 1) for i in range(n)]
l.sort(key=lambda x: x.time)
m = []
total = 0
for j in range(n):
	total += Instrument.__getTime__(l[j])
	if total > k:
		print(j)
		if j > 0:
			print(' '.join(m))
		break
	else:
		m.append(str(Instrument.__getPosition__(l[j])))
	if total == k or j == n - 1:
		print(j + 1)
		print(' '.join(m))
		break


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
if sum(arr) <= k:
	print(n)
	print(*list(range(1, n + 1)))
	exit()
mapping = {key: val for (key, val) in enumerate(arr, start=1)}
sor = sorted(mapping.items(), key=lambda x: x[1])
ans = []
for (i, val) in sor:
	k -= val
	if k >= 0:
		ans.append(i)
print(len(ans))
print(*ans)


def fking(li):
	return li[0]
(n, k) = input().split()
(n, k) = (int(n), int(k))
li1 = list(map(int, input().split()))
li2 = []
for i in range(n):
	tl = (li1[i], i)
	li2.append(tl)
li2.sort(key=fking)
cn1 = 0
cn2 = 0
li3 = []
for i in range(n):
	if cn2 + li2[i][0] <= k:
		cn1 += 1
		li3.append(li2[i][1] + 1)
		cn2 += li2[i][0]
	else:
		break
if cn1 == 0:
	print(0)
else:
	print(cn1)
	otpt = ' '.join((str(i) for i in li3))
	print(otpt)


(n, k) = input().split()
n = int(n)
k = int(k)
a = []
l = [int(x) for x in input().split()]
for i in range(n):
	a.append((i + 1, l[i]))
a.sort(key=lambda x: x[1])
s = 0
i = 0
ans = []
count = 0
while s <= k and i < n:
	s += a[i][1]
	if s <= k:
		ans.append(a[i][0])
		i += 1
		count += 1
print(count)
for i in range(len(ans)):
	print(ans[i], end=' ')


(n, k) = map(int, input().split())
a = [(i, x) for (i, x) in enumerate(map(int, input().split()), 1)]
a = sorted(a, key=lambda x: x[1])
ct = 0
ids = []
for (i, x) in a:
	if ct + x > k:
		break
	ct += x
	ids.append(i)
print(len(ids))
print(' '.join(map(str, ids)))


(N, D) = map(int, input().split())
days = list(map(int, input().split()))
for (i, d) in enumerate(days):
	days[i] = [d, i]
days.sort(key=lambda x: x[0])
ans = 0
re = []
ind = 0
while ind < len(days) and D >= days[ind][0]:
	D -= days[ind][0]
	re += [days[ind][1] + 1]
	ans += 1
	ind += 1
print(ans)
for r in re:
	print(r, end=' ')


[n, k] = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
b = [0] * n
for i in range(n):
	b[i] = {'index': i + 1, 'value': a[i]}
a = sorted(b, key=lambda item: item['value'])
r = []
while len(a) > 0 and k >= a[0]['value']:
	t = a.pop(0)
	k = k - t['value']
	r.append(t['index'])
print(n - len(a))
print(*r)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

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

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
(n, m) = di()
a = li()
temp = []
for i in range(n):
	temp.append([a[i], i + 1])
temp.sort()
ans = []
for i in range(n):
	if temp[i][0] <= m:
		m -= temp[i][0]
		ans.append(temp[i][1])
print(len(ans))
print(*ans)


(n, k) = map(int, input().split())
inp = input().split()
arr = [(int(inp[i]), i + 1) for i in range(len(inp))]
arr.sort()
sum = 0
ans = []
i = 0
while sum + arr[i][0] <= k:
	sum += arr[i][0]
	ans.append(arr[i][1])
	i += 1
	if i == n:
		break
print(len(ans))
print(*ans)


(n, k) = map(int, input().split())
a = [(j, i) for (i, j) in enumerate(map(int, input().split()), 1)]
a = sorted(a)
t = []
count = 0
total = 0
for i in range(n):
	total += a[i][0]
	if total <= k:
		count += 1
	else:
		break
for i in range(count):
	t.append(str(a[i][1]))
print(count)
print(' '.join(t))


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = {}
t = 1
for i in a:
	d[i, t] = 0
	t += 1
b = sorted(d)
S = 0
num = 0
c = []
for i in range(n):
	S += b[i][0]
	c.append(str(b[i][1]))
	num += 1
	if S > k:
		c.pop()
		c.sort()
		print(num - 1)
		print(' '.join(c))
		exit()
c.sort()
print(num)
print(' '.join(c))


ins = input().split()
n = int(ins[0])
m = int(ins[1])
ins = input().split()
a = []
for i in range(n):
	a.append([i + 1, int(ins[i])])
a.sort(key=lambda x: x[1])
xx = 0
ans = []
for i in range(n):
	if xx + a[i][1] > m:
		break
	xx += a[i][1]
	ans.append(a[i][0])
print(len(ans))
for ii in ans:
	print(ii, end=' ')


nk = list(map(int, input().split()))
days = list(map(int, input().split()))
ind = []
for i in range(len(days)):
	ind.append(days[i])
s = 0
if sum(days) <= nk[1]:
	print(nk[0])
	for i in range(1, nk[0] + 1):
		print(i, end=' ')
elif sum(days) > nk[1]:
	while sum(days) > nk[1]:
		days.remove(int(max(days)))
	print(len(days))
	for i in range(len(days)):
		if days[i] in ind:
			print(ind.index(days[i]) + 1, end=' ')
			ind[ind.index(days[i])] = -1


(q, a) = map(int, input().split())
b = input().split()
for i in range(q):
	b[i] = int(b[i])
totalDays = 0
totalInstru = 0
c = []
for i in b:
	c.append(i)
b.sort()
nums = []
i = 0
while not totalDays > a and i < len(b):
	totalDays += b[i]
	totalInstru += 1
	nums.append(c.index(b[i]))
	c[c.index(b[i])] = ' '
	i += 1
if totalDays > a:
	totalInstru -= 1
	totalDays -= b[i - 1]
	nums = nums[0:-1]
print(totalInstru)
for i in range(len(nums) - 1):
	print(int(nums[i]) + 1, end=' ')
if len(nums) != 0:
	print(int(nums[-1]) + 1)


nk = input().split()
n = int(nk[0])
k = int(nk[1])
a = list(map(int, input().split()))
a1 = sorted(a)
i = 0
l = []
while k > 0:
	if a1[i] <= k:
		l.append(a1[i])
		k -= a1[i]
		i += 1
		if i >= len(a1):
			break
	else:
		break
if len(l) == 0:
	print(0)
else:
	print(len(l))
	for i in range(0, len(a)):
		if a[i] in l:
			print(i + 1, end=' ')
			l.remove(a[i])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
ans = []
total = 0
count = 0
for i in b:
	total += i
	if total <= k:
		count += 1
if count == n:
	print(n)
	print(*list(range(1, n + 1)))
else:
	for i in range(count):
		if b[i] == b[i + 1]:
			if i == count - 1 and len(set(ans)) != count:
				ans += [j + 1 for j in range(len(a)) if a[j] == b[i]]
				while len(ans) > count:
					ans.pop()
			else:
				pass
		elif a.count(b[i]) == 1:
			ans.append(a.index(b[i]) + 1)
		else:
			ans += [j + 1 for j in range(len(a)) if a[j] == b[i]]
			while len(ans) > count:
				ans.pop()
	print(count)
	print(*set(ans))


(a, b) = input().split(' ')
n = int(a)
k = int(b)
l = [int(i) for i in input().split(' ')]
if n == 1 and k < max(l):
	print('0')
else:
	l1 = []
	count = 0
	for i in range(len(l)):
		l1.append(l[i])
	l1.sort()
	l2 = []
	learn = 0
	for i in range(n):
		learn += l1[i]
		if k >= learn:
			l2.append(l1[i])
		else:
			continue
	print(len(l2))
	str1 = ''
	for i in range(len(l2)):
		a = l.index(l2[i])
		l[a] = 0
		str1 += str(a + 1)
		str1 += ' '
	print(str1)


import math
import sys
import itertools
import random

def lcm(x, y):
	return x * y // math.gcd(x, y)

def hcf(x, y):
	return math.gcd(x, y)
(x, y) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
l2 = [[l[a], a] for a in range(0, x)]
l = [f for f in l2]
l.sort()
res = 0
r = []
counter = 0
while y > 0:
	if counter >= x:
		break
	if l[counter][0] <= y:
		y -= l[counter][0]
		r.append(l[counter][1] + 1)
		res += 1
	else:
		break
	counter += 1
if res == 0:
	print(0)
else:
	print(res)
	print(*r)


s1 = input()
a = s1.split(' ')
n = int(a[0])
k = int(a[1])
s2 = input()
ar = s2.split()
arr = []
for i in range(len(ar)):
	arr.append(int(ar[i]))
soar = sum(arr)
d = soar - k
if d <= 0:
	print(len(ar))
	for i in range(len(ar)):
		print(i + 1)
else:
	while d > 0:
		m = max(arr)
		for i in range(n):
			if arr[i] == m:
				arr[i] = 0
				break
		d = sum(arr) - k
	s = len(arr) - arr.count(0)
	print(s)
	for i in range(n):
		if arr[i] != 0:
			print(i + 1, end=' ')


x = input()
x = x.split()
(n, k) = map(int, x)
y = input()
y = y.split()
for i in range(n):
	y[i] = [int(y[i]), i + 1]
y.sort()
temp = 0
ans = 0
while ans < n and temp + y[ans][0] <= k:
	temp = temp + y[ans][0]
	ans += 1
print(ans)
for i in range(ans):
	print(y[i][1], end=' ')


import operator
(n, k) = map(int, input().split())
d = sorted(enumerate(map(int, input().split())), key=operator.itemgetter(1))
val = []
for x in d:
	if k >= x[1]:
		val.append(x[0] + 1)
		k -= x[1]
	else:
		break
print(len(val))
print(' '.join(map(str, val)))


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

def main():
	(n, k) = map(int, input().split())
	t = list(map(int, input().split()))
	arr = []
	s = 0
	while k >= 0:
		try:
			k -= min(t)
		except:
			break
		if k < 0:
			break
		arr.append(t.index(min(t)) + 1)
		t.insert(t.index(min(t)) + 1, 123321)
		t.pop(t.index(min(t)))
		s += 1
	print(s)
	arr.sort()
	arr = list(map(str, arr))
	print(' '.join(arr))
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')
main()


read = lambda : map(int, input().split())
(n, k) = read()
a = list(read())
a = sorted([(a[i], i + 1) for i in range(n)])
cur = 0
ans = []
for (val, ind) in a:
	if cur + val > k:
		break
	cur += val
	ans.append(ind)
print(len(ans))
print(*ans)


(n, k) = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
a = []
t = 0
while t < k and len(a) < n:
	m = min(l)
	if m + t <= k:
		a.append(l.index(m) + 1)
		l[l.index(m)] = 101
	t += m
print(len(a))
if len(a) > 0:
	print(' '.join((str(s) for s in a)))


(n, m) = map(int, input().split())
L = list(map(int, input().split()))
L1 = [k + 1 for k in range(n)]
L2 = [0] * n
for k in range(n):
	L2[k] = (L[k], L1[k])
L2 = sorted(L2)
suma = 0
L3 = []
for k in range(n):
	suma += L2[k][0]
	if suma <= m:
		L3 += [str(L2[k][1])]
	else:
		break
print(len(L3))
if len(L3) != 0:
	print(' '.join(L3))


(n, k) = input().split()
(n, k) = (int(n), int(k))
a = input()
A = []
x = 0
for i in a.split():
	A.append([int(i), x])
	x = x + 1
A.sort()
Sum = 0
B = []
b = 0
for j in range(0, n):
	Sum = Sum + A[j][0]
	if Sum <= k:
		B.append(A[j][1])
		b = b + 1
	else:
		break
B.sort()
s = ''
if len(B) == 0:
	print(0)
else:
	print(b)
	for l in B:
		s = s + str(l + 1) + ' '
	print(s)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = a[:]
b.sort()
ans = []
i = 0
while k > 0:
	if i == len(a):
		break
	if k - b[i] >= 0:
		k -= b[i]
		ans.append(a.index(b[i]) + 1)
		a[a.index(b[i])] = -1
		i += 1
	else:
		break
print(len(ans))
print(*(ans or ''))


(a, b) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
o = []
for i in range(a):
	o.append((l[i], i + 1))
o.sort()
sum = 0
j = 0
while sum < b and j < a:
	sum += o[j][0]
	j += 1
p = []
if sum <= b:
	for i in range(j):
		p.append(str(o[i][1]))
	print(len(p))
	print(' '.join(p))
else:
	for k in range(j - 1):
		p.append(str(o[k][1]))
	if int(len(p)) > 0:
		print(len(p))
		print(' '.join(p))
	else:
		print(0)


(n, k) = map(int, input().split())
a = []
answer = 0

def f(b):
	b = tuple(b)
	return b[0]
a = input().split()
for i in range(n):
	a[i] = [int(a[i]), i + 1]
a.sort(key=f)
j = 0
while j <= n - 1:
	if answer + a[j][0] <= k:
		answer += a[j][0]
	else:
		break
	j += 1
print(j)
for i in range(j):
	print(a[i][1], end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dist = [0] * n
l = []
pos = 0
aux = 0
for i in range(n):
	dist[i] = (a[i], i + 1)
dist = sorted(dist)
soma = dist[0][0]
while soma <= k:
	pos += 1
	aux += 1
	if pos >= n:
		break
	soma += dist[pos][0]
for i in range(aux):
	l.append(str(dist[i][1]))
l = sorted(l)
print(aux)
if aux != 0:
	print(' '.join(l))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append([a[i], i + 1])
b.sort()
ans = []
for i in range(n):
	if k >= b[i][0]:
		k -= b[i][0]
		ans.append(b[i][1])
	else:
		break
print(len(ans))
if len(ans) > 0:
	print(*ans)


(n, k) = map(int, input().split())
r = lambda : list(map(int, input().split()))
arr = list(enumerate(r(), 1))
arr.sort(key=lambda x: x[1])
ans = []
for (pos, val) in arr:
	if k - val < 0:
		break
	k -= val
	ans.append(pos)
print(len(ans))
print(*ans)


(n, k) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = list(sorted(enumerate(A), key=lambda x: x[1]))
total = 0
count = 0
for i in B:
	if total + i[1] <= k:
		count += 1
		total += i[1]
	else:
		break
print(count)
print(' '.join([str(B[i][0] + 1) for i in range(count)]))


(n, k) = input().split()
n = int(n)
k = int(k)
time = {}
ts = 0
line = [int(i) for i in input().split()]
for i in range(n):
	while (line[i], ts) in time:
		ts += 1
	time[line[i], ts] = i
a = sorted(time)
optimal = []
num = 0
for i in a:
	if k >= i[0]:
		k -= i[0]
		num += 1
		optimal.append(str(time[i] + 1))
print(num)
print(' '.join(optimal))


def bin_search(array, element, lb, rb):
	l = list(array)
	s = list(element)
	n = len(l)
	left = int(lb)
	right = int(rb)
	while left + 1 != right:
		mid = (right + left) // 2
		if s[0] > l[mid][0]:
			left = mid
		else:
			right = mid
	return right

def list_insert(a, n, left, right):
	if n[0] >= a[right][0]:
		a.insert(right + 1, n)
	elif n[0] <= a[left][0]:
		a.insert(left, n)
	else:
		a.insert(bin_search(a, n, left, right), n)

def insertion_sort(array):
	l = list(array)
	n = len(l)
	for i in range(1, n):
		val = l[i]
		l.pop(i)
		list_insert(l, val, 0, i - 1)
	return l

def main():
	read = input().split()
	n = int(read[0])
	k = int(read[1])
	read = input().split()
	a = [[int(read[i]), i] for i in range(len(read))]
	a = insertion_sort(a)
	days = 0
	count = 0
	for i in range(len(a)):
		days += a[i][0]
		if days > k:
			break
		count += 1
	print(count)
	for i in range(count):
		print(a[i][1] + 1, end=' ')
main()


(n, m) = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = []
sum = 0
count = len(list1)
for i in range(len(list1)):
	if min(list1) > m and i == 0:
		print(0)
		return
	if sum + min(list1) <= m:
		sum += min(list1)
		list2.append(list1.index(min(list1)) + 1)
		list1[list1.index(min(list1))] = 999999999999
print(len(list2))
print(' '.join(map(str, list2)))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(n):
	l.append((a[i], i + 1))
l.sort()
cnt = 0
p = []
s = 0
k = 0
for i in range(n):
	s = s + l[i][0]
	if s <= m:
		cnt += 1
		p.append(l[i][1])
	else:
		print(cnt)
		print(*p)
		k = 1
		break
if k == 0:
	print(cnt)
	print(*p)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
ans = []
for i in range(n):
	ans += [(a[i], i + 1)]
ans.sort(key=lambda x: x[0])
if ans[0][0] > k:
	print(0)
else:
	sm = 0
	res = []
	for i in range(n):
		sm += ans[i][0]
		if sm <= k:
			res += [ans[i][1]]
		else:
			break
	print(len(res))
	print(*res)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
s = sorted(((l[i], i + 1) for i in range(n)))
s1 = False
l1 = []
for (i, j) in s:
	if k - i >= 0:
		l1.append(j)
		k = k - i
		s1 = True
if s1 == False:
	print(0)
else:
	print(len(l1))
	print(*l1)


(n, k) = map(int, input().split())
a1 = [int(i) for i in input().split()]
a2 = [(a1[i], i + 1) for i in range(n)]
b = []
a2.sort()
for i in range(n):
	if a2[i][0] > k:
		break
	b.append(a2[i][1])
	k -= a2[i][0]
b.sort()
print(len(b))
for i in b:
	print(i, end=' ')
print()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
bb = k
rip = 0
cou = 0
z = []
while k >= 0 and cou < len(a):
	b = min(a)
	ind = a.index(b)
	k -= b
	rip += b
	cou += 1
	z.append(ind + 1)
	a[ind] = 100001
if rip > bb:
	z.pop()
if len(z) == 0:
	print(0)
else:
	print(len(z))
	print(*z)


(n, tot) = map(int, input().split())
arr = []
for (i, x) in enumerate(input().split()):
	arr.append([i + 1, int(x)])
arr.sort(key=lambda x: x[1])
j = 0
sum = 0
ans = []
while j < n and tot >= sum + arr[j][1]:
	sum += arr[j][1]
	ans.append(arr[j][0])
	j += 1
print(j)
if j != 0:
	print(*ans)


(n, k) = map(int, input().split())
di2 = list(map(int, input().split()))
di = sorted(di2)
summ = 0
j = 0
dj = [0] * n
for i in di:
	summ += int(i)
	if summ <= k:
		dj[j] = di2.index(int(i)) + 1
		di2[int(dj[j]) - 1] = 0
		j += 1
	else:
		break
print(j)
for i in range(j):
	print(dj[i], end=' ')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l2 = list(l)
l2.sort()
s = 0
r = []
for i in l2:
	if s + i <= b:
		s += i
		r.append(l.index(i) + 1)
		l[l.index(i)] = 90000
print(len(r))
if len(r) > 0:
	for i in r:
		print(str(i) + ' ', end='')


import sys
(n, m) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
b = []
c = []
summa = 0
for i in range(n):
	b.append(i + 1)
i = 0
while i < n - 1:
	if a[i] > a[i + 1]:
		t = a[i]
		a[i] = a[i + 1]
		a[i + 1] = t
		t = b[i]
		b[i] = b[i + 1]
		b[i + 1] = t
		i = -1
	i += 1
for i in range(n):
	if summa + a[i] > m:
		break
	else:
		summa += a[i]
		c.append(b[i])
print(c.__len__())
c = sorted(c)
for i in range(c.__len__()):
	if i == c.__len__() - 1:
		print(c[i], end='')
	else:
		print(c[i], end=' ')


__author__ = 'artyom'
read = lambda : map(int, input().split())
(n, k) = read()
a = sorted([(x, j) for (j, x) in enumerate(read())])
(s, i) = (0, 0)
ans = []
while i < n:
	s += a[i][0]
	if s > k:
		break
	ans.append(str(a[i][1] + 1))
	i += 1
print(i)
print(' '.join(ans))


(n, k) = [int(x) for x in input().split()]
times = [int(x) for x in input().split()]
maxElement = max(times)
tmp = []
label = []
for x in times:
	tmp.append(x)
for i in range(0, maxElement + 1):
	label.append(0)
tmp.sort()
total = tmp[0]
numOfIns = 0
while total <= k:
	label[tmp[numOfIns]] += 1
	numOfIns += 1
	if numOfIns == n:
		break
	total += tmp[numOfIns]
print(numOfIns)
for i in range(0, n):
	if label[times[i]] != 0:
		print(i + 1, end=' ')
		label[times[i]] -= 1


(n, k) = map(int, input().split())
data = list(map(int, input().split()))
for i in range(n):
	data[i] = [data[i], i]
data.sort()
c = 0
index = 0
answer = []
while index < n and c + data[index][0] <= k:
	answer.append(data[index][1] + 1)
	c += data[index][0]
	index += 1
print(len(answer))
print(*answer)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
y = x.copy()
(cnt, i) = (0, 0)
a = []
y.sort()
while i < n and k >= y[i]:
	cnt += 1
	a.append(x.index(y[i]) + 1)
	x[x.index(y[i])] = 0
	k -= y[i]
	i += 1
print(cnt)
print(*a)


from __future__ import division, print_function
from collections import *
from math import *
from itertools import *
from time import time
import os
import 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 main():
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	checks = defaultdict(list)
	for i in range(1, n + 1):
		checks[li[i - 1]].append(i)
	check = OrderedDict(sorted(checks.items()))
	avaliable = []
	count = 0
	for j in check:
		for l in check[j]:
			if k - j >= 0:
				count += 1
				avaliable.append(str(l))
				k -= j
			else:
				continue
	print(count)
	print(' '.join(avaliable))
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')
main()


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
count = 0
f = 0
d = []
g = 0
c = 0
h = a[:]
s = a[:]
l = 0
q = max(a) + 1
if sum(a) <= k:
	count = len(a)
	for i in range(len(a)):
		d.append(i + 1)
else:
	for i in range(len(s)):
		c = min(s)
		f += c
		if f <= k:
			count += 1
			d.append(s.index(c) + 1)
			s.insert(s.index(c), q)
			s.remove(c)
		else:
			break
print(count)
print(*d)


(n, k) = list(map(int, input().split()))
a = [(value, index) for (index, value) in enumerate(map(int, input().split()), 1)]
a.sort()
result = []
i = 0
while i < len(a) and k >= a[i][0]:
	result.append(a[i][1])
	k -= a[i][0]
	i += 1
print(len(result))
print(' '.join(map(str, result)))


(n, k) = map(int, input().split())
t = [(j, i) for (i, j) in enumerate(map(int, input().split()), 1)]
t.sort()
t.append((0, 0))
i = 0
while i < n and k >= t[i][0]:
	k -= t[i][0]
	i += 1
print(i)
print(' '.join(map(str, (j for (i, j) in t[:i]))))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [[a[i], i + 1] for i in range(n)]
b.sort()
c = 0
r = []
for j in range(n):
	if k - b[j][0] >= 0:
		c = c + 1
		k = k - b[j][0]
		r.append(b[j][1])
print(c)
print(*r)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
resList = list()
for (a, b) in sorted(zip(l, range(n))):
	if a <= k:
		resList.append(b + 1)
		k -= a
print(len(resList))
print(' '.join(map(str, resList)))


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
a = s[:]
s.sort()
max_col_ans = 0
ans = []
for x in s:
	if k >= x:
		k -= x
		max_col_ans += 1
		ans.append(str(a.index(x) + 1))
		a[a.index(x)] = max(a) + 1
print(max_col_ans)
print(' '.join(ans))


def sum1(a):
	s = 0
	for i in range(len(a)):
		s += a[i][0]
	return s
(n, k) = map(int, input().split())
d1 = list(map(int, input().split()))
d = []
for i in range(n):
	d.append([d1[i], i + 1])
d.sort()
s = sum1(d)
j = n
while s > k:
	j -= 1
	s = sum1(d[0:j])
print(j)
for i in range(j):
	print(d[i][1], end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(range(n + 1))[1:]
b = sorted(b, key=lambda x: a[x - 1])
i = 0
tot = 0
while tot <= k and i < len(a):
	tot += a[b[i] - 1]
	i += 1
if tot <= k:
	print(n)
	print(' '.join(map(str, b)))
else:
	print(i - 1)
	if i - 1 != 0:
		print(' '.join(map(str, b[:i - 1])))


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in range(1, n + 1)]
i = 0
while i < n - 1:
	if a[i] > a[i + 1]:
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		(b[i], b[i + 1]) = (b[i + 1], b[i])
		i = -1
	i += 1
h = x = 0
for i in range(n):
	h += a[i]
	if h > k:
		break
	x += 1
print(x)
for i in range(x):
	print(b[i], end=' ')


(n, k) = (int(x) for x in input().split())
li = list(map(int, input().split()))
ar = [(x, i) for (i, x) in enumerate(li)]
ar.sort()
sm = 0
count = 0
for x in ar:
	sm += x[0]
	if sm > k:
		break
	count += 1
print(count)
k = ''
for x in ar[:count]:
	k += str(x[1] + 1) + ' '
print(k)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = a
s = sorted(a)
m = 0
for i in range(0, n):
	d = sum(s[0:i])
	e = sum(s[0:i + 1])
	if d <= k and e > k:
		m = i
		break
if k >= sum(s):
	m = n
print(m)
for i in range(0, m):
	print(a.index(s[i]) + 1, end=' ')
	a[a.index(s[i])] = -1


(n, k) = map(int, input().split())
t = [(j, i) for (i, j) in enumerate(map(int, input().split()), 1)]
t.sort()
c = 0
sol = []
for i in t:
	c += i[0]
	if c > k:
		break
	else:
		sol.append(i[1])
print(len(sol))
for xx in sol:
	print(xx, end=' ')


(_, k) = input().split()
instruments = [(int(i), n) for (n, i) in enumerate(input().split(), 1)]
instruments.sort()
total = 0
result = []
for (i, n) in instruments:
	total += i
	if total > int(k):
		break
	result.append(str(n))
print(len(result))
print(' '.join(result))


def main():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.append(sum(l) + k)
	li = sorted(range(n + 1), key=l.__getitem__)
	for (i, a) in enumerate(li):
		k -= l[a]
		if k < 0:
			print(i)
			print(' '.join((str(_ + 1) for _ in li[:i])))
			break
main()


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
li = []
li = li + l
l = sorted(l)
if sum(l) <= b:
	i = a
else:
	for i in range(a):
		if sum(l[:i + 1]) > b:
			break
print(i)
for j in range(i):
	print(li.index(l[j]) + 1, end=' ')
	li[li.index(l[j])] = -1


(n, k) = input().split()
a = input().split()
aa = []
for i in range(len(a)):
	aa.append([a[i], str(i + 1)])
aa.sort()
max = 0
ins = []
for i in range(int(n)):
	if max + int(aa[i][0]) > int(k):
		continue
	else:
		max += int(aa[i][0])
		ins.append(aa[i][1])
print(len(ins))
print(' '.join(ins))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
d = 1
l = list([0])
vis = [0] * n
(sumo, cnt, j) = (0, 0, 0)
a.sort()
for i in range(n):
	if sumo + a[i] <= k:
		sumo += a[i]
		for j in range(n):
			if a[i] == b[j] and vis[j] == 0:
				vis[j] = 1
				l.append(j + 1)
				break
print(len(l) - 1)
for i in l[1:]:
	print(i, end=' ')


(n, k) = map(int, input().split())
a = list(zip(range(n), map(int, input().split())))
b = []
s = 0
a.sort(key=lambda item: item[1])
for i in a:
	if s + i[1] <= k:
		s += i[1]
		b.append(i[0] + 1)
	else:
		break
print(len(b))
print(' '.join(map(str, b)))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
d = {}
ans = []
for i in range(len(a)):
	d[i + 1] = a[i]
x = list(d.values())
x.sort()
for i in x:
	k -= i
	if k >= 0:
		ans.append(list(d.values()).index(i) + 1)
		d[list(d.values()).index(i) + 1] = 0
	else:
		break
print(len(ans))
for i in ans:
	print(i, end=' ')


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, k) = LI()
	a = LI()
	b = sorted([(a[i], i + 1) for i in range(n)])
	r = []
	for (c, d) in b:
		k -= c
		if k < 0:
			break
		r.append(d)
	return '{}\n{}'.format(len(r), ' '.join(map(str, r)))
print(main())


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(a)
d = []
c = 0
i = 0
while c < k and i < n:
	c += b[i]
	d.append(a.index(b[i]) + 1)
	a[a.index(b[i])] = 0
	i += 1
if c > k:
	d.pop()
print(len(d))
for i in d:
	print(i, end=' ')


(n, k) = map(int, input().split())
a = sorted(zip(map(int, input().split()), range(1, 1 + n)))
(r, s) = ([], 0)
for i in a:
	s += i[0]
	if s <= k:
		r.append(i[1])
print(len(r))
print(*r)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
li1 = list(enumerate(li, 1))
li1.sort(key=lambda x: x[1])
li3 = []
count = 0
for i in li1:
	m -= i[1]
	if m >= 0:
		count += 1
		li3.append(i[0])
print(count)
print(*li3)


x = list(map(int, input().split()))
y = list(map(int, input().split()))
k = x[1]
p = []
if min(y) > k:
	print(0)
elif min(y) == k:
	print(1)
	print(y.index(min(y)) + 1)
else:
	s = 0
	for i in range(len(y)):
		s = s + min(y)
		if s > k:
			break
		else:
			q = y.index(min(y))
			p.append(q + 1)
			y[q] = max(y) + 1
	print(len(p))
	print(' '.join(map(str, p)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
set_ = []
for i in range(len(a)):
	b.append([a[i], i])
b.sort()
s = 0
c = 0
for i in range(len(b)):
	if s + b[i][0] > k:
		break
	else:
		s = s + b[i][0]
		c = c + 1
		set_.append(b[i][1] + 1)
if c != 0:
	print(c)
	print(*set_)
else:
	print('0')


(n, d) = input().split()
n = int(n)
d = int(d)
a = list(map(int, input().strip().split()))[:n]
dd = sorted(a)
x = 0
y = 0
c = 0
b = []
pp = 0
while x + dd[0] <= d:
	y = dd[0]
	b.append(a.index(y))
	pp = a.index(y)
	a[pp] = -1
	x = x + y
	dd.remove(y)
	c = c + 1
	if len(dd) == 0:
		break
print(c)
for i in range(len(b)):
	print(b[i] + 1, end=' ')


from operator import itemgetter
(n, k) = map(int, input().split())
lst_a = list(zip(range(1, n + 1), map(int, input().split())))
lst_a_sorted = sorted(lst_a, key=itemgetter(1))
res_a = []
sum_res_a = 0
for tuple_idx_a in lst_a_sorted:
	if sum_res_a + tuple_idx_a[1] <= k:
		res_a.append(tuple_idx_a[0])
		sum_res_a += tuple_idx_a[1]
	else:
		break
print(len(res_a))
print(' '.join([str(x) for x in res_a]))


(n, k) = input().split(' ')
n = int(n)
k = int(k)
d = list(map(int, input().split()))
a = [(d[i], i + 1) for i in range(len(d))]
s_a = sorted(a)
i = 0
sum1 = 0
while sum1 <= k and i < len(a):
	sum1 += s_a[i][0]
	i += 1
if sum1 > k:
	i -= 1
print(i)
for iter1 in range(i):
	print(s_a[iter1][1], end=' ')


import sys, functools
import functools
(n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
daysList = [int(a_temp) for a_temp in input().strip().split(' ')]
daysListSupport = sorted(daysList)
sum = 0
pos = 0
for x in range(0, n):
	sum += daysListSupport[x]
	if sum >= k:
		pos = x
		if sum == k:
			pos = x + 1
		break
else:
	pos = n
print(pos)
for x in range(0, pos):
	loc = daysList.index(daysListSupport[x])
	print(loc + 1, end=' ')
	daysList[loc] = 0


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
new = []
ans = []
s = 0
for i in range(n):
	new.append([l[i], i + 1])
new.sort()
for i in range(n):
	s += new[i][0]
	if s <= k:
		ans.append(new[i][1])
	else:
		break
if len(ans) == 0:
	print(0)
else:
	print(len(ans))
	print(*ans)


R = lambda : map(int, input().split())
(n, k) = R()
t = []
for (a, b) in sorted(zip(R(), range(n))):
	if k >= a:
		t += [b + 1]
		k -= a
print(len(t))
print(' '.join(map(str, t)))


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = sorted(a)
result = []
days_used = 0
for i in range(n):
	if days_used + b[i] <= k:
		days_used += b[i]
		result.append(a.index(b[i]) + 1)
		a[a.index(b[i])] = 0
	else:
		break
print(len(result))
print(' '.join((str(i) for i in result)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = [a[i], i + 1]
b = sorted(a)
c = t1 = 0
ans = ''
for i in range(n):
	c += b[i][0]
	if c > k:
		break
		t1 = i
	ans += str(b[i][1]) + ' '
	t1 = i + 1
print(t1)
print(ans)


(n, k) = map(int, input().split())
a = []
for (i, j) in enumerate(map(int, input().split())):
	a.append((j, i + 1))
a.sort()
ans = []
c = 0
for (i, j) in a:
	if c + i <= k:
		ans.append(j)
		c += i
	else:
		break
if len(ans) == 0:
	ans = []
print(len(ans))
print(*ans)


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
d = {}
for i in range(n):
	d[i] = a[i]
dict(sorted(d.items(), key=lambda item: item[1]))
a.sort()
sum = 0
res = []
for i in a:
	sum += i
	if sum > k:
		break
	res.append(i)
print(len(res))
for i in res:
	print(list(d.keys())[list(d.values()).index(i)] + 1, end=' ')
	d[list(d.keys())[list(d.values()).index(i)]] = 0


from collections import Counter
gi = lambda : list(map(int, input().strip().split()))
(n, m) = gi()
l = gi()
l = [(l[k], k + 1) for k in range(n)]
l.sort()
ans = []
for e in l:
	m -= e[0]
	if m >= 0:
		ans.append(e[1])
	if m <= 0:
		break
print(len(ans))
print(' '.join(map(str, ans)))


import sys
n_k = input().split()
ai = input().split()
my_dict = {}
for i in range(0, int(n_k[0])):
	my_dict[i] = int(ai[i])
dict = sorted(my_dict.items(), key=lambda x: x[1])
sum = 0
i = 0
for key in dict:
	sum += key[1]
	if sum == int(n_k[1]):
		i += 1
		break
	elif sum < int(n_k[1]):
		i += 1
	else:
		break
print(i)
for j in range(0, i):
	sys.stdout.write(str(dict[j][0] + 1) + ' ')


(n, k) = map(int, input().split())
li = [int(x) for x in input().split()]
z = sorted(li)
s = i = 0
out = []
while s < k and i < n:
	if s + z[i] > k:
		break
	s += z[i]
	for x in range(n):
		if li[x] == z[i]:
			li[x] = -1
			out.append(x + 1)
			break
	i += 1
print(len(out))
print(*out)


from operator import itemgetter
(n, k) = map(int, input().split())
index = lambda x: x[0] + 1
days = itemgetter(1)
line = lambda x: ' '.join(map(str, x))
a = sorted(enumerate(map(int, input().split())), key=days)
s = 0
for i in range(n):
	if s + days(a[i]) <= k:
		s += days(a[i])
	else:
		print(i)
		print(line(map(index, a[:i])))
		exit()
print(n)
print(line(range(1, n + 1)))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
p = max(l)
a = []
while k >= 0:
	m = min(l)
	if m == p + 1:
		break
	k -= m
	c += 1
	if k < 0:
		c -= 1
		break
	else:
		i = l.index(m)
		a.append(i + 1)
		l[i] = p + 1
print(c)
print(*a)


import math, os, sys
import string, re
import itertools, functools, operator
from collections import Counter

def inputint():
	return int(input())

def inputarray(func=int):
	return map(func, input().split())
(n, k) = inputarray()
A = filter(lambda x: x[1] <= k, itertools.accumulate(sorted(enumerate(inputarray()), key=lambda x: x[1]), lambda x, y: (y[0], x[1] + y[1])))
res = list(zip(*A))
if len(res) > 0:
	res = res[0]
print(len(res))
print(' '.join(map(lambda x: str(x + 1), res)))


(n, k) = str(input()).split()
n = int(n)
k = int(k)
line = str(input()).split()
line = [int(it) for it in line]
raw_line = line.copy()
line.sort()
pos = n
for i in range(1, n + 1):
	if sum(line[:i]) > k:
		pos = i - 1
		break
print(pos)
if pos > 0:
	final_line = list()
	last_p = 0
	curr_p = 0
	last_v = 0
	curr_v = 0
	for i in range(pos):
		curr_v = line[i]
		if curr_v > last_v:
			curr_p = raw_line.index(line[i]) + 1
		else:
			curr_p = raw_line.index(line[i], last_p) + 1
		final_line.append(curr_p)
		last_v = curr_v
		last_p = curr_p
	final_line = [str(it) for it in final_line]
	print(' '.join(final_line))


(n, k) = map(int, input().split())
days = list(map(int, input().split()))
aux = list(days)
aux.sort()
sum = 0
res = []
for i in aux:
	sum += i
	if sum <= k:
		index = days.index(i)
		res.append(index + 1)
		days[index] = -1
	else:
		break
print(len(res))
print(' '.join(map(str, res)))


nk = list(map(int, input().strip().split()))
n = nk[0]
k = nk[1]
arr = list(map(int, input().strip().split()))
arr2 = sorted(arr)
flag = True
i = s = 0
l = []
while i < n and arr2[i] + s <= k:
	l.append(arr2[i])
	s += arr2[i]
	i += 1
if s == 0:
	print(0)
else:
	l2 = []
	for j in range(len(arr)):
		if arr[j] in l:
			l2.append(j + 1)
			l.remove(arr[j])
	print(i)
	print(*l2)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
ins = 0
INS = []
while k - min(L) >= 0:
	k -= min(L)
	i = L.index(min(L))
	INS += [i + 1]
	ins += 1
	L[i] = 10001
if ins == 0:
	print(0)
else:
	print(ins)
	for i in INS[:-1]:
		print(i, end=' ')
	print(INS[-1])


(n, k) = map(int, input().split())
data = list(map(int, input().split()))
data = sorted(zip(data, range(1, len(data) + 1)), key=lambda x: x[0])
inst = []
for x in data:
	if k < x[0]:
		break
	inst.append(x[1])
	k -= x[0]
print(len(inst))
print(' '.join(map(str, inst)))


def ans():
	(n, k) = [int(i) for i in input().split()]
	vals = [int(i) for i in input().split()]
	outs = []
	while k - min(vals) >= 0 and len(outs) < len(vals):
		outs.append(vals.index(min(vals)) + 1)
		k -= min(vals)
		vals[vals.index(min(vals))] = 101
	print(len(outs))
	print(' '.join([str(outs[i]) for i in range(len(outs))]))
	return
ans()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = (a[i], i + 1)
a.sort()
i = 0
s = 0
b = []
while i < n and s < k:
	if s + a[i][0] <= k:
		s += a[i][0]
		i += 1
	else:
		break
print(i)
for i in range(i):
	b.append(a[i][1])
print(*b)


(k, n) = map(int, input().split())
temp = input().split()
data = []
i = 1
for item in temp:
	data.append([int(item), i])
	i += 1
data.sort()
cost = 0
answer = []
for item in data:
	if item[0] + cost <= n:
		cost += item[0]
		answer.append(item[1])
	else:
		break
print(len(answer))
if len(answer) != 0:
	for i in range(len(answer) - 1):
		print(answer[i], end=' ')
	print(answer[-1])


l1 = [int(x) for x in input().split()]
(n, k) = (l1[0], l1[1])
l2 = [[int(x)] for x in input().split()]
for x in range(len(l2)):
	l2[x].append(x + 1)
l2.sort(reverse=True)
c = []

def catorse(listo):
	temp = 0
	for x in listo:
		temp += x[0]
	return temp
while l2 and catorse(c) < k:
	c.append(l2.pop())
if catorse(c) > k:
	c.pop()
c = [x[1] for x in c]
print(len(c))
print(*c)


x = []
w = []
T = []
(n, k) = map(int, input().split())
x = input().split()
for b in range(len(x)):
	x[b] = int(x[b])
z = x.copy()
z.sort()
i = 0
tot = 0
if sum(z) <= k:
	print(n)
	for i in range(1, len(x) + 1):
		T.append(i)
	print(*T, sep=' ')
elif z[0] > k:
	print(0)
else:
	while tot <= k:
		if tot + z[i] > k:
			break
		else:
			tot += z[i]
			w.append(z[i])
		i += 1
	print(i)
	counter = 0
	while len(T) != i:
		if x[counter] in w:
			T.append(counter + 1)
			w[w.index(x[counter])] = 'x'
		counter += 1
	print(*T, sep=' ')


(n, m) = map(int, input().strip().split()[:2])
l = list(map(int, input().strip().split()[:n]))
k = l.copy()
k.sort()
z = []
for x in range(len(k)):
	if k[x] <= m:
		m -= k[x]
		z.append(l.index(k[x]) + 1)
		l[l.index(k[x])] = ''
if len(z) == 0:
	print(0)
else:
	print(len(z))
	print(*z)


(n, k) = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
d = []
while k > 0:
	z = a.index(min(a))
	if a[z] <= k:
		k -= a[z]
		d.append(z + 1)
		a[z] = 9999
	else:
		break
d.sort()
print(len(d))
print(' '.join([str(_) for _ in d]))


import sys
(n, k) = [int(x) for x in sys.stdin.readline().split()]
st = sys.stdin.readline().split()
an = []
for i in range(n):
	an.append((int(st[i]), i + 1))
an.sort(key=lambda x: x[0])
res = []
sum = 0
c = 0
for i in range(n):
	sum += an[i][0]
	if sum > k:
		break
	c += 1
	res.append(str(an[i][1]))
print(c)
print(' '.join(res))


import bisect
(n, k) = map(int, input().split())
A = list(map(int, input().split()))
sorted_A = sorted(A)
now = 0
L = []
for a in sorted_A:
	now += a
	L.append(now)
right = bisect.bisect_right(L, k)
if right == 0:
	print(0)
	exit()
d = {}
for i in range(right):
	d[sorted_A[i]] = d.get(sorted_A[i], 0) + 1
ans = []
for i in range(n):
	if A[i] in d and d[A[i]] != 0:
		ans.append(i + 1)
		d[A[i]] -= 1
print(right)
print(' '.join(map(str, ans)))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = l[:]
y = []
x.sort()
i = 0
while m > 0 and i < len(l):
	if x[i] <= m:
		y.append(l.index(x[i]) + 1)
		l[l.index(x[i])] = max(l) + 1
	m = m - x[i]
	i = i + 1
y.sort()
if len(y) > 0:
	print(len(y))
	print(*y)
else:
	print(0)


(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
ans = []
for i in range(n):
	ans.append((l[i], i + 1))
ans.sort()
i = 0
c = 0
sum = 0
z = []
while i < n and sum + ans[i][0] <= m:
	sum += ans[i][0]
	z.append(ans[i][1])
	i += 1
	c += 1
print(c)
if c:
	print(*z)


(k, n) = map(int, input().split())
ll = list(map(int, input().split()))
ll1 = [0] * 101
for i in range(k):
	if ll1[ll[i]] == 0:
		ll1[ll[i]] = str(i + 1)
	else:
		ll1[ll[i]] = ll1[ll[i]] + ' ' + str(i + 1)
otvet = ''
otvet1 = 0
for i in range(101):
	if ll1[i] != 0:
		for j in ll1[i].split():
			if n - i >= 0:
				n = n - i
				otvet = otvet + str(j) + ' '
				otvet1 += 1
			else:
				break
print(otvet1)
print(otvet if len(otvet) > 0 else '')


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline

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

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
(n, k) = li()
a = li()
for i in range(n):
	a[i] = [i, a[i]]
a.sort(key=lambda x: x[1])
tot = k
ans = []
for i in range(n):
	if tot >= a[i][1]:
		tot -= a[i][1]
		ans.append(a[i][0] + 1)
	else:
		break
print(len(ans))
print(*ans)


(n, k) = input().split()
n = int(n)
a = list(map(int, input().split(' ', n)))
extra = a[:]
output = []
string = ''
k = int(k)
while k > 0:
	instrument = min(a)
	index = extra.index(instrument) + 1
	output.append(index)
	a.remove(instrument)
	if extra.count(instrument) > 1:
		extra.pop(index - 1)
		extra.insert(index - 1, 101)
	if k - instrument < 0:
		output.pop()
		break
	if a == []:
		break
	k -= instrument
if output == []:
	output.append(0)
for element in output:
	string += str(element) + ' '
if output != [0]:
	print(len(output))
print(string)


def mn(ms):
	ret = min(ms)
	index = ms.index(ret)
	ms[index] = 101
	return [ret, index]
(n, k) = [int(i) for i in input().split()]
ms = [int(i) for i in input().split()]
mx = max(ms)
ret = []
days = 0
p = 0
for i in range(len(ms)):
	box = mn(ms)
	if days + box[0] <= k:
		days += box[0]
		ret.append(box[1] + 1)
		p += 1
print(p)
if ret != []:
	for i in ret:
		print(i, end=' ')


(n, k) = map(int, input().split())
A = sorted(((a, i) for (i, a) in enumerate(map(int, input().split()), 1)))
(instruments, days) = (set(), 0)
for (a, i) in A:
	days += a
	if days > k:
		break
	else:
		instruments.add(i)
print(len(instruments))
print(*instruments)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
t = 0
ans = []
for (i, e) in sorted(enumerate(a, 1), key=lambda x: x[1]):
	if t + e > k:
		break
	else:
		t += e
		ans.append(i)
print(len(ans))
if len(ans) > 0:
	print(' '.join(map(str, ans)))


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
a = []
tot = 0
for i in range(n):
	a.append([b[i], i + 1])
	tot += a[i][0]
a.sort()
pos = 0
if tot <= k:
	pos = n
else:
	for i in range(n):
		if k >= a[i][0]:
			k -= a[i][0]
		else:
			pos = i
			break
print(pos)
for i in range(pos):
	print(a[i][1], end=' ')


(n, d) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a = [[str(i + 1), a[i]] for i in range(n)]
a = sorted(a, key=lambda x: x[1])
x = 0
c = list()
for i in range(n):
	x += a[i][1]
	c.append(a[i][0])
	if x > d:
		c = c[:-1]
		break
if len(c) == 0:
	print('0')
	quit()
else:
	print(len(c))
	print(' '.join(c))


from sys import stdin, stdout
import math
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
count = 0
u = k
ans = []
for i in range(len(arr)):
	d = arr.index(min(arr))
	if k < arr[d]:
		break
	else:
		k -= arr[d]
		ans.append(d + 1)
		arr[d] = u
print(len(ans))
if len(ans) > 0:
	for i in range(len(ans)):
		stdout.write(str(ans[i]) + ' ')


(n, d) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append((a[i], i))
b.sort(key=lambda x: x[0])
a = []
s = 0
c = 0
for i in b:
	s += i[0]
	if s <= d:
		a.append(i[1] + 1)
		c += 1
	else:
		break
if c != 0:
	print(c)
	print(*a)
else:
	print(c)


(n, k) = map(int, input().split())
a = []
i = 1
for x in input().split():
	a.append([int(x), i])
	i += 1
a.sort()
s = 0
i = 0
tools = 0
while True:
	s += a[i][0]
	if s > k:
		break
	tools += 1
	if i == len(a) - 1:
		break
	i += 1
print(tools)
s = ''
for i in range(tools):
	s += str(a[i][1]) + ' '
print(s)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in a]
b.sort()
(p, c, d) = (0, [], [])
for i in b:
	p += i
	if p <= k:
		c.append(i)
	else:
		break
ans = len(c)
print(ans)
for i in range(len(a)):
	if a[i] in c:
		d.append(i + 1)
		c.remove(a[i])
for i in d:
	print(i, end=' ')


I = lambda : map(int, input().split())
(n, k) = I()
l = sorted(zip(I(), range(1, n + 1)))
h = []
for (i, j) in l:
	k -= i
	if k >= 0:
		h.append(j)
print(len(h))
print(*h)


(n, k) = map(int, input().split())
ara = list(map(int, input().strip().split()))
for i in range(n):
	ara[i] = (ara[i], i + 1)
ara = sorted(ara)
ans = []
j = 0
total = 0
for i in range(n):
	if total + ara[i][0] > k:
		break
	total += ara[i][0]
	ans.append(ara[i][1])
ans = sorted(ans)
print(len(ans))
for i in ans:
	print(i, end=' ')


(n, v) = [int(k) for k in input().split()]
w = [int(k) for k in input().split()]
w = [[w[k], k + 1] for k in range(len(w))]
w.sort(key=lambda x: x[0])
res = 0
q = []
for j in w:
	if j[0] > v:
		break
	else:
		v -= j[0]
		q.append(j[1])
		res += 1
print(res)
if res:
	print(' '.join([str(k) for k in q]))


(n, k) = map(int, input().split())
sum = 0
l2 = []
l = sorted([(x, i) for (i, x) in enumerate(map(int, input().split()), 1)])
for (i, j) in l:
	sum = sum + i
	if sum <= k:
		l2.append(j)
print(len(l2))
for h in l2:
	print(h, end=' ')


def sortl(inp):
	return inp[0]
(n, k) = map(int, input().split(' '))
mas = [[x, i] for (i, x) in enumerate(map(int, input().split(' ')))]
mas.sort(key=sortl)
res = 0
for i in range(n):
	k -= mas[i][0]
	if k >= 0:
		res += 1
	else:
		break
print(res)
for i in range(res):
	print(mas[i][1] + 1, end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = [(a[i], i + 1) for i in range(len(a))]
l = 0
a.sort()
for i in a:
	k -= i[0]
	if k < 0:
		break
	l += 1
if l == 0:
	print(l)
else:
	print(l)
	for i in a[:l]:
		print(i[1], end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
t = []
for (a, b) in sorted(zip(l, range(n))):
	if a <= k:
		t.append(b + 1)
		k -= a
print(len(t))
for x in t:
	print(x, end=' ')


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = []
q = 1
for i in a:
	b += [(i, q)]
	q += 1
b.sort()
s = 0
l = ''
for (i, q) in b:
	if k >= i:
		s += 1
		k -= i
		l += str(q) + ' '
	else:
		break
print(s)
print(l)


(n, m) = input().split()
n = int(n)
m = int(m)
a = input().split()
b = {i: int(a[i - 1]) for i in range(1, n + 1)}
b = sorted(b.items(), key=lambda x: x[1])
count = 0
ans = []
for item in b:
	if item[1] <= m:
		m -= item[1]
		count = count + 1
		ans.append(item[0])
ans = sorted(ans)
print(count)
print(' '.join((str(v) for v in ans)))


(m, n) = map(int, input().split())
l = list(map(int, input().split()))
k = l.copy()
k.sort()
(a, flag) = (0, 0)
for i in range(m):
	a += k[i]
	if a == n:
		i = i + 1
		flag = 1
		break
	elif a > n:
		flag = 1
		break
if flag == 1:
	print(i)
else:
	print(m)
	i = m
for j in range(i):
	print(l.index(k[j]) + 1, end=' ')
	l[l.index(k[j])] = -1


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
(n, k) = zzz()
arr = zzz()
arr = sorted([(i, j + 1) for (j, i) in enumerate(arr)])
ans = []
for i in arr:
	if i[0] <= k:
		ans.append(i[1])
		k -= i[0]
print(len(ans))
print(*ans)


import sys
input = sys.stdin.readline

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 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)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

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):
	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
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 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()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	(n, k) = map(int, input().split())
	a = [[x, i + 1] for (i, x) in enumerate(list(map(int, input().split())))]
	a.sort()
	summ = 0
	ans = []
	for x in a:
		if summ + x[0] <= k:
			summ += x[0]
			ans.append(x[1])
	if summ > 0:
		print(len(ans))
		print(*ans)
	else:
		print(0)
for _ in range(1):
	solve()


(n, k) = map(int, input().split())
arr = sorted(list(zip(range(n), map(int, input().split()))), key=lambda x: x[1])
ans = []
i = 0
while k - arr[i][1] >= 0:
	k -= arr[i][1]
	ans.append(arr[i][0] + 1)
	i += 1
	if i == n:
		break
print(len(ans))
print(*ans)


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
lsind = []
for i in range(n):
	lsind.append((ls[i], i + 1))
ans = []
s = 0
for x in sorted(lsind):
	s += x[0]
	if s <= k:
		ans.append(x[1])
	else:
		break
print(len(ans))
print(*ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [[None] + [i + 1] for i in range(n)]
for i in range(n):
	b[i][0] = a[i]
b.sort()
pos = 0
s = 0
while pos < n and s < k:
	s += b[pos][0]
	pos += 1
if s > k:
	pos -= 1
print(pos)
for i in range(pos - 1):
	print(b[i][1], end=' ')
if pos:
	print(b[pos - 1][1])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = [(y, x) for (x, y) in enumerate(arr)]
arr.sort()
cnt = 0
ans = []
for (x, y) in arr:
	if k >= x:
		k -= x
		cnt += 1
		ans.append(y + 1)
print(cnt)
if len(ans) > 0:
	print(' '.join(map(str, ans)))


from sys import stdin

def main():
	inp = stdin
	a = [int(x) for x in inp.readline().split()]
	while len(a) != 0:
		b = [int(x) for x in inp.readline().split()]
		for u in range(len(b)):
			b[u] = [b[u], u + 1]
		b.sort()
		s = 0
		c = 0
		for i in range(a[0]):
			s += b[i][0]
			if s <= a[1]:
				c += 1
		print(c)
		if c > 0:
			for i in range(c):
				print(b[i][1], end=' ')
		a = [int(x) for x in inp.readline().split()]
main()


(n, k) = map(int, input().split())
inst = [int(i) for i in input().split()]
inst_copy = [[i, j] for (i, j) in enumerate(inst)]
inst_copy.sort(key=lambda x: x[1])
inst_used = []
for i in range(n):
	if k < inst_copy[i][1]:
		break
	inst_used.append(inst_copy[i][0] + 1)
	k -= inst_copy[i][1]
inst_used.sort()
print(len(inst_used))
print(' '.join([str(i) for i in inst_used]))


import math
import os
import random
import re
import sys
from operator import itemgetter, attrgetter
(n, k) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
(b, p, s) = (list(), 0, '')
for i in range(n):
	b.append((i + 1, a[i]))
b.sort(key=itemgetter(1))
while p < n and k - b[p][1] >= 0:
	k -= b[p][1]
	p += 1
print(p)
for x in range(p):
	s += str(b[x][0])
	s += ' '
print(s.lstrip())


def musical_instrument(n, k, a):
	if sum(a) <= k:
		print(n)
		print(' '.join(list(map(str, list(range(1, n + 1))))))
	else:
		total = sum(a)
		dup = sorted(a.copy())
		while total > k and len(dup) > 0:
			total -= dup[-1]
			dup.pop(-1)
		if len(dup) == 0:
			print(0)
		else:
			print(len(dup))
			ans = []
			j = 0
			while j < n:
				if a[j] in dup:
					ans.append(str(j + 1))
					dup.remove(a[j])
				j += 1
			print(' '.join(ans))
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
musical_instrument(n, k, a)


import sys
days = int(input().split()[1])
instruments = list(map(int, input().split()))
pos = ''
count = 0
while days > 0:
	i = instruments.index(min(instruments))
	if days - instruments[i] >= 0:
		pos += ' %d ' % (i + 1)
		days -= instruments[i]
		count += 1
		instruments[i] = sys.maxsize
	else:
		break
print(count)
print(pos.strip())


(n, m) = map(int, input().split())
y = list(map(int, input().split()))
x = []
for i in range(n):
	x.append([y[i], i + 1])
x.sort(key=lambda i: i[0])
c = 0
i = 0
while i < n:
	c += x[i][0]
	if c > m:
		break
	i += 1
print(i)
for j in range(i):
	print(x[j][1], end=' ')


(n, k) = map(int, input().split())
a = list(map(lambda p: (p[1], p[0]), enumerate(map(int, input().split()), start=1)))
a.sort()
s = 0
m = 0
while m < len(a) and s + a[m][0] <= k:
	s += a[m][0]
	m += 1
print(m)
print(' '.join([str(x[1]) for x in a[:m]]))


n_k = list(map(int, input().split()))
n = n_k[0]
k = n_k[1]
LA = list(map(int, input().split()))
L = LA.copy()
L.sort()
S = 0
I = []
for i in range(len(L)):
	el = L[i]
	if S + el <= k:
		S = S + el
		j = LA.index(el, 0) + 1
		if not j in I:
			I.append(j)
		else:
			for m in range(len(I)):
				if j in I:
					j = LA.index(el, j) + 1
			I.append(j)
	else:
		break
print(len(I))
print(' '.join(map(str, I)))