생성일: 2022년 1월 24일 오후 5:23
# 가장 큰 수
import sys
sys.stdin = open("input2.txt" ,"rt")
n, m = map(int, input().split())
cnt = 0
res = []
n = list(str(n))
n = list(map(int, n))
while len(n) != 0:
a = n.pop(0)
if len(res) == 0:
res.append(a)
else:
while len(res) != 0:
if res[-1] < a and cnt < m:
res.pop()
cnt += 1
else:
break
res.append(a)
if cnt < m:
for _ in range(m-cnt):
res.pop()
for x in res:
print(x, end='')
import sys
sys.stdin=open("input.txt", "rt")
num, m=map(int, input().split())
num=list(map(int, str(num)))
stack=[]
for x in num:
while stack and m>0 and stack[-1]<x:
stack.pop()
m-=1
stack.append(x)
if m!=0:
stack=stack[:-m]
res=''.join(map(str, stack))
print(res)