#include <fstream>
#include <string>
#include <deque>

using namespace std;

void FindMax(string &a, int &b, deque <char> &ans)
{
	long long len = a.length();
	long long max = 0, i;
	for (i = 0; i < len; i++)
	{
		while (!ans.empty() && b > 0)
		{
			if (a[i] > ans.back())
			{
				ans.pop_back();
				b--;
			}
			else break;
		}
		ans.push_back(a[i]);
	}
	while (b > 0)
	{
		b--;
		ans.pop_back();
	}
}

int main()
{
	ifstream input("xaumax.inp");
	ofstream output("xaumax.out");

	string a;
	deque <char> ans;
	int b;
	int max = INT32_MIN;
	input >> a;
	input >> b;
	for (int i = 0; i < a.length(); i++)
	{
		if (a[i] < 48 || a[i] > 57)
		{
			a.erase(a.begin() + i);
			i--;
			b--;
		}
	}
	FindMax(a, b, ans);
	while (!ans.empty())
	{
		output << ans.front();
		ans.pop_front();
	}
	input.close();
	output.close();
}