Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer.Help Pasha count the maximum number he can get if he has the time to make at most k swaps.

The single line contains two integers a and k (1 ≤ a ≤ 1018; 0 ≤ k ≤ 100).

Print the maximum number that Pasha can get if he makes at most k swaps.

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define DEBUG(debug_x) cerr <<#debug_x<<": "<<debug_x<<endl;
#define DEBUG2(debug_x, debug_y) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<endl;
#define DEBUG3(debug_x, debug_y, debug_z) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<" "<<#debug_z<<":"<<debug_z<<endl;
#define DEBUGVC(debug_x) cerr <<#debug_x<<": "; for(auto a:debug_x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(debug_x) cerr <<#debug_x<<":"<<endl; for(auto a:debug_x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (2000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;

int func(string a){
	int res=0;
	int n = a.length();
	int k = 1;
	for(int i=n-1; i>=0; i--){
		res += (a[i]-'0')*k;
		k*=10;
	}
	//DEBUG(res);
	return res;
}

signed main() {
	string a;
	int k;
	cin >> a >> k;
	int n = a.length();

	if(n==1 || k==0){
		cout << a << endl;
		return 0;
	}

	int ans=func(a);

	while(1){
		//DEBUG2(ans, k);
		string b=a;
		a = b;
		int p = k;
		bool f=false;
		int ans2=ans;
		int q = 0;
		for(int i=0; i<n; i++){
			if(q >= a[i]-'0') continue;
			int m = k;
			string c = a;
			//DEBUG2(i,c);
			for(int j=i; j>0; j--){
				if(m==0) break;
				swap(c[j],c[j-1]);
				//DEBUG(a);
				m--;
				int val = func(c);
				//DEBUG3(c, q, c[j-1]);
				if(ans2 < func(c)){
					f=true;
					ans2 = func(c);
					p = m;
					b = c;
					q = c[j-1]-'0';
				}

			}
			//DEBUG2(i, b);
		}
		if(!f) break;
		ans = ans2;
		a = b;
		k = p;
		//DEBUG2(ans, k);
		if(k==0) break;
	}

	cout << ans << endl;

}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int k,pos;
	char maxx = '0';
	scanf("%d",&k);
	for(int i = 0; i < s.length(); i++)
	{
		pos = i;
		for(int j = i + 1; j <= i + k && j < s.length(); j++)
		{
			if(s[j] > s[pos]) pos = j;
		}
		if(pos == i) continue;
		for(int j = pos; j > i; j--)
		{
			swap(s[j],s[j - 1]);
		}
		k -= pos - i;
		if(!k) break;
	}
	cout<<s;
	return 0;
}

#include <iostream>

using namespace std;
int k;
string s;
void solve(int ind){
   int x=ind-1;
  for(int i=x;i>=0;i--){
      if(s[ind]>s[i] && k>0){
          k--;
          swap(s[ind],s[i]);
          ind--;
          //cout<<s<<endl;
      }
    else
        break;
  }
}
int main()
{
    cin>>s>>k;
    int n=s.size();
    int y=n-k-1;
    if(y<=0)y=n-1;
    for(int i=0;i<=y;i++){
            int e=i+k,ind=i;
            char x=s[i];
            if(e>=n)e=n-1;
      //cout<<y<<endl;
      //cout<<i<<' '<<e<<endl;
         for(int j=i;j<=e;j++){
              if(s[j]>x){
                x=s[j];
                ind=j;
              }}
        //cout<<ind<<' '<<x<<endl;
            solve(ind);
       if(k==0)break;
         y=n-k-1;
        if(y<=0)y=n-1;
        else
            y=n+i-k-1;
    }
      cout<<s<<endl;

    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int k,c=0,k1;
    string x,y,z;
    cin >> x;
    y = x;
    z = x;

    sort(y.begin(), y.end());
    sort(z.begin(), z.end());
    reverse(z.begin(), z.end());
    cin >> k;
    k1 = k;
    if (k == 0)
    {
        cout << x << endl;
    }
    else if (x == z)
    {
        cout << x << endl;
    }

    else
    {
        for (int i = 0; i+1< x.size(); i++)
        {
            int t = i;
            for (int j = i + 1; j < x.size() && j - i <= k; j++)
            {

                if (x[j] > x[ t])
                {
                    t = j;
                }
            }
            k -= t - i;
            while (t != i)
            {
                swap(x[t], x[t-1]);
                t--;
            }

        }
        cout << x << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
ll n,c;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int k;
    int x=101;
    char maxi='0';
    cin>>s>>k;
    if(s.size()==1)return cout<<s<<endl,0;
    for(int i=0; i<s.size(); i++)
    {
        int pos=i;
        for( int j=i;j < (int)min((int)s.size(),(int)i+k+1);j++){
            if(s[pos]<s[j]){
                pos=j;
            }
        }
        k-=(pos-i);
        for(int k=pos;k>i;k--){
            swap(s[k],s[k-1]);
        }
    }
    cout<<s<<endl,0;

    return 0;
}

/*

                 """Bismillahir Rahmanur Rahim"""

*/
#include<bits/stdc++.h>
using namespace std;
void shikariIsListening()
{
#ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);
#endif
}
#define pi 2*acos(0.0)
#define ll long long int
#define inf 922337203470075000LL
#define pb push_back
#define pf push_front
#define ek(x) __builtin_popcount(x)
#define ses '\n'
#define in(x) scanf("%lld",&x);
#define out(x) printf("%lld\n",x);
#define stm istringstream
#define all(x) x.begin(),x.end()
#define gcd __gcd
ll lcm(ll x,ll y)
{
    return (x*y)/gcd(x,y);
}
#define tin ll T;cin>>T; for(ll o=1;o<=T;o++)
#define tout cout<<"Case "<<o<<":\n";
#define spc printf(" ");
#define vll vector<ll>
#define pii pair<ll,ll>
#define fs first
#define sc second
#define sz 100015
bool cmp(pii x,pii y)
{
    if(x.fs==y.fs)
        return x.sc<y.sc;
    else
        return x.fs>y.fs;
}
bool vis[155];
int main()
{
    //shikariIsListening();
    string s;
    ll x;
    cin>>s;
    cin>>x;
    vector<pii>v;
    ll n=s.size();
    for(ll i=0; i<s.size(); i++)
    {
        v.pb({s[i]-'0',i});
    }

    sort(all(v),cmp);
    for(ll i=0; i<n||x>0; i++)
    {
        if(i>=n)
            break;

        for(ll j=0; j<n; j++)
        {

            if((s[i]-'0')>=v[j].fs)
                continue;
            ll p=abs(v[j].sc-i);
            if(p<=x)
            {
                if(v[j].sc>i)
                {
                    vis[j]=1;
                    x-=p;
                    for(ll k=v[j].sc; k>i; k--)
                        swap(s[k],s[k-1]);
                           v.clear();
                    for(ll i=0; i<s.size(); i++)
                    {
                        v.pb({s[i]-'0',i});
                    }

                    sort(all(v),cmp);

                    break;
                }

            }
        }
    }
    cout<<s<<ses;

}
/*   --------------------
    |      ~SOHAN~       |
    |   ~ShikariSohan~   |
     --------------------
    || VALAR MORGULIS||==|| ALL MEN MUST DIE ||
    \ Power Is Power//
    || I Can Do This All day ||
    // We are on a Break \ // How you doin'? \
    || Say My Name || ~~ || I Am The Who Knocks ||
    // I Am Ted Mosby Architect \
    || It Is Legen --wait for it -- dary ,Legendary ||
    \ Penny - Penny - Penny // -- Bazinga

*/

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    string str;cin>>str;
    int k;cin>>k;
    for(int i=0;i<str.size()&&k;++i){
        int indx,mx=-1;
        for(int j=i ; j<min((int)str.size(),i+k+1) ; j++)
            if(str[j]-'0'>mx)mx=str[j]-'0',indx=j;
        k-=indx-i;
        for(int j=indx ; j>i ; j--)swap(str[j],str[j-1]);
    }
    cout<<str;
    return 0;
}

#include<iostream>
#include<string.h>
using namespace std;
int n, m;
char s[105];
int main()
{
  while (cin >> s >> n)
  {
    for (int i=0;i<strlen(s);i++)
    {
    	if (n<=0)
    		break;
    	if (s[i]=='9')
    		continue;
    	char ma=s[i];
    	int p=0;
    	for (int j=1;j<=n;j++)
    	{
    		if (ma<s[i+j])
    		{
    			ma=s[i+j];
    			p=j;
    		}
    	}
    	n=n-p;
    	for (int k=p+i-1;k>=i;k--)
    		swap(s[k],s[k+1]);
    }
    cout << s << endl;
    memset(s,0,sizeof(s));
  }
   return 0;
}

/*
 * Author: Omar_Elaraby
 * Created: ٢٠١٩-٠٩-١٠ ٨:٢٠:٤٣ ص
 */
//#include "stdafx.h"
#include <bits/stdc++.h>
using namespace std;

bool not_sorted(const string &str, const int start, const int end) {
	for (int i = start; i <= end; ++i) {
		for (int j = i + 1; j <= end; ++j) {
			if (str[i] < str[j]) return true;
		}
	}
	return false;
}

int mx(const string &str, const int start, const int end) {
	char ans = str[start], idx = start;
	for (int i = start + 1; i <= end; ++i) {
		if (str[i] > ans) {
			ans = str[i];
			idx = i;
		}
	}
	return idx;
}

void swp(string &str, int start, int idx) {
	for (int i = idx; i > start; --i) {
		swap(str[i], str[i - 1]);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	string str;
	int k;
	cin >> str >> k;

	int start = 0, end = start + k;
	if (end >= str.size()) end = str.size() - 1;
	while (k > 0 && start < (int) str.size()) {
		if (not_sorted(str, start, end)) {
			int idx = mx(str, start, end);
			swp(str, start, idx);
			k -= (idx - start);

		}
		++start;
		end = start + k;
		if (end >= str.size()) end = str.size() - 1;

	}

	cout << str << '\n';
	return 0;
}

/*
 stuff you should look for :
 - set TLE
 - tricky/special/corner test cases
 - 2D array maybe cause MLE & TLE

 - int overflow, array bounds
 - (a / b) (a % b) be careful ((b may 0)) // RTE
 - var = arr[i] or i. var holds value or index ?
 - cout << ceil(something)
 // ceil and floor return 'double' so cast them to (int or long long) if necessary

 - Time is enough to do every thing so please please stay calm and organized.
 -* LEARN FROM YOUR MISTAKES *-
 */

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
    char num[25];
    char trans[25];
    string tem;
    int k;
    while (cin >> tem >> k)
    {
        memset(num, 0, sizeof(num));
        memset(trans, 0, sizeof(trans));
        int i = 0;
        for (string::iterator c = tem.begin(); c != tem.end(); c++,i++)
        {
            num[i] = *c;
        }
        int j = 0;

        while (k>0&&j!=tem.size()-1)
        {
            int m=0,mi=0;
            for (int i = j; i <=j + k&&i<25; i++)
            {
                if (m<num[i] - '0')
                {
                    m = num[i] - '0';
                    mi = i;
                }

            }
            if (m > num[j] - '0')
            {
                for (int p = j; p < mi ; p++)
                    trans[p + 1] = num[p];

                num[j] = m+'0';
                for (int p = j + 1; p <= mi; p++)
                    num[p] = trans[p];

                k -= (mi - j);
            }
            j++;
        }
        for (int i = 0; i < tem.size(); i++)
            cout << num[i];
        cout << endl;
    }

}

#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std ;

#define sz size()
#define eps 1e-9
#define inf 1 << 28
#define pb push_back
#define del( a , b ) memset( a , b , sizeof ( a ) )

char a[23];
int main()
{
    int k , i , j ;
    scanf("%s %d",a,&k) ;
    int l = strlen(a) ;
    for( i=0 ; i<l ; i++ )
    {
        int best = i ;
        for( j=i+1 ; j<l && j<=i + k ; j++ )
            if ( a[j] > a[best] )
                best = j;
        if( best != i)
        {
            for( j=best ; j>i ; j-- )
            {
                swap(a[j], a[j - 1]);
                k--;
            }
        }
    }
    printf("%s\n", a);
    return 0;
}

#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

/*ll NcR(ll n, ll r)
{
    ll p = 1, k = 1;
    if (n - r < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;
            ll m = __gcd(p, k);
            p /= m;
            k /= m;

            n--;
            r--;
        }
    }
    else
        p = 1;

    return p;
} */

int main()
{
    _fastio
    string s;
    ll k;
    cin>>s>>k;

    for(ll i=0;i<s.size();i++)
    {
        char mx;
        ll idx;
        for(ll j=i+1;j<s.size();j++)
        {
            if(j==i+1)
            {
                mx=s[j];
                idx=j;
            }
            else
            {
                if(s[j]>mx && j-i<=k)
                {
                    mx=s[j];
                    idx=j;
                }
            }
        }
        //cout<<mx<<" "<<idx<<en;
        if(mx>s[i])
        {
            ll nd=idx-i;
            if(nd<=k)
            {
                ll t=idx;
                while(t!=i)
                {
                    swap(s[t],s[t-1]);
                    t-=1;
                }
                k-=nd;
            }
        }
    }
    cout<<s<<en;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

#define MAX 100

int k, n, i, d, j, _;
char s[MAX];

int max ()
{
	int t, maxx;
	t = i + k;
	if (t > n) t = n;
	maxx = i + 1;
	d = 1;
	if (i + 2 < n + 1)
		for (_ = i + 2; _ <= i + k; _++)
			if (s[_] > s[maxx])
			{
				maxx = _;
				d = _ - i;
			}
	return maxx;
}

int main ()
{
	//freopen ("input1.txt", "r", stdin);
	scanf ("%s", s);
	scanf ("%d", &k);
	n = strlen(s) - 1;
	i = 0;
	while (k > 0)
	{
		if (i == n) break;
		j = max();
		if (s[i] < s[j])
		{
			for (_ = j - 1; _ >= i; _--)
				swap(s[_], s[_ + 1]);
			k -= d;
			i++;
		}
		else i++;
	}
	printf ("%s", s);
	return 0;
}

#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define rev(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1e9 + 7;
const int MAX = 1e5+10;
const int p = 1e9 + 7;

int main()
{
    std::ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);

    string a; int k;
    cin>>a>>k;
    int n = a.size();

    if (k == 0) {
		cout << a << endl;
		return 0;
	}

    for(int i = 0 ; i<n-1;i++)
    {
    	int bigIndex = i;
    	//cout<<k<<"\n";
    	for(int j = i+1; j<=i+k && j<n; j++)
    		if(a[j]>a[bigIndex])
    			bigIndex = j;

    	for(int m = bigIndex ; m>i; m--)
    			swap(a[m] , a[m-1]);

    	k -= (bigIndex - i);

    }
    cout<<a;
}

#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <unordered_set>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <list>
#include <fstream>
#define ull unsigned long long
#define ll long long
#define ld long double
#define pi 3.1415926536
#define lp(i,n,a) for(ll i=a;i<=n;i++)
#define pl(i,n) for(ll i=n-1;i>=0;i--)
#define w while
#define re return
// Hard Training :D
// hossam yehia //
using namespace std;
ll n, k, x, num, c, f;
string s;
char mini;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> k;
	n = s.size();
	n--;
	if (k >= (n*(n + 1) / 2)) {
		sort(s.begin(), s.end());
		reverse(s.begin(), s.end());
		cout << s << endl;
		re 0;
	}
	n++;
	lp(i, n - 1, 0) {
		c = num = 0;
		mini = s[i];
		if (k) {
			lp(j, i + k, i + 1) {
				if (j >= n)
					break;
				c++;
				if (s[j] > mini)
					x = j, num = 1, f = c, mini = s[j];
			}
			if (num) {
				k -= f;
				ll on = x;
				w(f--)
					swap(s[on], s[on - 1]), on--;
			}
		}
		else
			break;
	}
	cout << s << endl;
	cin >> n;
	re 0;
}

#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
int main() {
    string str;
    int k;
    cin>>str>>k;
    int p = 0,q,i,ind;
    int x = str.length();
    while(k)
    {
        if(p==(str.length()-1))
        break;
        ind = p;
        char tmp = str[p];
        for(i=p;i<min(x,p+k+1);i++)
        {
            if(str[i]>tmp)
            {
                tmp = str[i];
                ind = i;
            }
        }
        for(q=ind;q>p;q--)
        swap(str[q],str[q-1]);

        k = k - (ind-p);
        //cout<<k<<" "<<p<<" "<<ind<<endl;
        p++;

    }
    cout<<str<<endl;
	return 0;
}

/*
                           \\\|///
                         \\  - -  //
                          (  @ @  )
O-----------------------oOOo-(_)-oOOo--------------------O
| CPP-file           *******                 IOI         |
|                by  *Jacob*	             IZhO        |
|                    *******                 BOI         |
|   <I_am_Champion>              Oooo        APIO        |
O------------------------oooO---(   )--------------------O
                        (   )   \  /
                        \  (    (_/
                         \_)
SITE: USACO
ID: allakov1
TASK:
LANG: C++
*/
#include<bits/stdc++.h>
//#include<conio.h>
#define pb(a) push_back(a)
#define pp() pop_back()
#define ff first
#define ss second
#define inf 1000000000
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ll  long long
using namespace std;
const int N=INT_MAX;
ll a,b,d,n,j,i,k,l,mx,mx_ind;
string s;
char c;
int main()
{
//	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s>>a;
//	if(s.length()==1) return cout<<s,0;
	while(a>0)
	{
		mx=s[i]-48;
		mx_ind=i;
		for(j=i+1;j<=i+a;j++)
		{
			if(j>=s.length()) break;
			k=s[j]-48;
			if(k>mx)
			{
				mx=k;
				mx_ind=j;
			}
		}
		c=s[mx_ind];
		for(j=mx_ind;j>i;j--)
		{
			s[j]=s[j-1];
		}
		s[i]=c;
		mx_ind-=i;
		a-=mx_ind;
//		cout<<i<<"  "<<s<<endl;
		if(i==s.length()) break;
		i++;
	}
	cout<<s;
	return 0;
}

#include <fstream>
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <ctype.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstring>
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vii;
typedef vector<long long> vll;
typedef vector< pair<long, long> > vpll;
typedef vector< pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;

int main (void)
{
    string a;
    int i, k, m,len;

    while(cin>>a>>k){
        len = a.size();

        if(k==0) cout<<a<<"\n";
        else{
            for(i=0; i<len; i++){
                if(a[i]=='9') continue;
                if(len<(i+k+1))
                    m = max_element(a.begin()+i+1,a.end()) - a.begin();
                else m = max_element(a.begin()+i+1,a.begin()+i+k+1) - a.begin();
                if(a[m]>a[i]){
                    a.insert(a.begin()+i,a[m]);
                    a.erase(a.begin()+m+1);
                    k -= (m-i);
                }
                if(k==0) break;
            }

            cout<<a<<"\n";
        }
    }

    return 0;
}

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include <numeric>
#include<math.h>
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll>
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 1<<20
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
#define coutd(x) cout << fixed << setprecision(x)
#define DECIMAL(n)  std::cout << std::fixed << std::setprecision(n);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define fil(v,x) fill(all(v),x)
#define filcon(v,x) iota(all(v),x)
#define newl '\n'

// #define INTMAX 200000000

// using namespace boost;
// #define si short int

using namespace std;
using namespace __gnu_pbds;
typedef priority_queue<ll, vector<ll > > max_pq;
typedef priority_queue<ll, vector<ll> , greater<ll>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

// using namespace __gnu_pbds;
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 20005
bool isInside(int circle_x, int circle_y,
                   int rad, int x, int y)
{
    // Compare radius of circle with distance
    // of its center from given point
    if ((x - circle_x) * (x - circle_x) +
        (y - circle_y) * (y - circle_y) <= rad * rad)
        return true;
    else
        return false;
}
int main()
{
    fio;
    string s;
    cin>>s;
    int k;
    cin>>k;
    //cout<<s<<" "<<k<<endl;
    int n = s.length();
    for(int i=0;i<s.length() && k>0;i++)
    {
        char grt=s[i];
        int index=i;
        for(int j=i;j<=min(i+k,n-1);j++)
        {
            if(s[j]>grt)
            {
                grt=s[j];
                index=j;
            }
        }
       // cout<<grt<<" "<<index<<newl;
        for(int j=index-1;j>=i && k>0;j--)
        {
            char x=s[j+1];
            s[j+1]=s[j];
            s[j]=x;
            k--;
        }
    }

    cout<<s;
}

#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;

char a[30];

int main()
{
    //freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int p=1;
    while(1)
    {
        scanf("%c",&a[p]);
        if(a[p]==' ')break;
        p++;
    }

    int k;
    scanf("%d",&k);
    p-=1;
  //  printf("%d\n%d\n",p,k);
    for(int i=1;i<=p;i++)
    {
        int xx=i;
        if(k<=0)break;
        char maxx=a[i];
        if(k+i<=p)
        {
            for(int j=i+1;j<=k+i;j++)
            if(maxx<a[j]){maxx=a[j];xx=j;}
        }
        else

            for(int j=i+1;j<=p;j++)
                if(maxx<a[j]){maxx=a[j];xx=j;}

        if(xx!=i)
        {
            for(int j=xx;j>i;j--)swap(a[j],a[j-1]);
            k-=xx-i;
        }

    }
   /* while(k--)
    {
        for(int i=1;i<p;i++)
            if(a[i]<a[i+1]){ swap(a[i],a[i+1]); break; }
    }*/

    for(int i=1;i<=p;i++)
        printf("%c",a[i]);

    return 0;

}

#include <bits/stdc++.h>
#define ll long long
#define omarshagar                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
ll gcd(ll a, ll b)
{
if(b==0)return a;
return gcd(b,a%b);

}
bool primes[100000]={};
void fill()
{
    primes[0]=1;
    primes[1]=1;
    for(ll i=0;i<100000;i++)
    {
        if(primes[i]==0)
        {
            for(ll ii=2;ii*i<100000;ii++)
            {
                primes[ii*i]=1;
            }
        }
    }
}
bool check(string x)
{
    for(int i=1;i<x.size();i++)
    {
        if(x[i]-'0'>x[i-1]-'0')return 1;
    }
    return 0;
}
int  main()
{
    omarshagar
   string x;
   int k;
   cin>>x>>k;

        //cout<<x;
        for(int i=0;i<x.size()&&k&&check(x);i++)
        {
          //  cout<<2;
            char m=x[i];
            int loc=-1;
            for(int ii=i+1;ii<=i+k&&ii<x.size();ii++)
            {
                if(x[ii]>m)
                {
                    m=x[ii];
                    loc=ii;
                }
            }
            if(loc==-1)continue;
            for(int ii=loc;ii>i;ii--)
            {
                swap(x[ii],x[ii-1]);
                k--;
            }
            if(!k)break;
        }

    cout<<x;
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
char data[20],b;
long long int tmp;
int swp;
int len;
int pos;
int mp,mn;
int main(){
	scanf("%s",data);
	scanf("%i",&swp);
	pos=0;
	len=strlen(data);
	if(swp==0||len==1){
		printf("%s\n",data);
		return 0;
	}
	int j,x1,x2,x,i;
	for(j = 0; j < len; j++){
        int x1=-1;
        for(i = j; i <= min(swp+j,len-1); i++){
            x=data[i]-'0';
            if(x>x1) x1=x,x2=i;
        }
        while(x2>j){
            b=data[x2-1];
            data[x2-1]=data[x2];
            data[x2]=b;
            swp--;
            x2--;
        }
    }
        printf("%s\n",data);
	return 0;
}

#include <iostream>
using namespace std;
#include<vector>
string s1;
vector<int>s;
void convert (long long int i,long long int j)
{
    char temp;
    while(j>i)
    {
        swap(s[j],s[j-1]);
        j-=1;
    }
}
int main()
{
    int k;
    cin>>s1>>k;
    long long int l = s1.length(),i,j;
    if(k==0)
    {
        cout<<s1<<endl;
        return 0;
    }
    for(i=0;i<l;i++)
    {
        s.push_back(s1[i]-48);
    }
    for(i=0;i<l;i++)
    {
        bool flag = false;
        if(s[i] == 9)
            continue;
        long long int temp = k,max = s[i],swap = 0;
        for(j=1;j<=temp and j+i<l;j++)
        {
            if(max<s[i+j])
            {

                max= s[j+i];
                swap = j;
                //cout<<j<<" : ";
            }
        }
        if(swap != 0)
        convert(i,i+swap);
        //cout<<swap<<" : "<<s<<endl;
        k=k-swap;
        if(k==0)
            break;
    }
    for(i=0;i<s.size();i++)
        cout<<s[i];
    cout<<endl;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

string s;
void FloatingNum(int from, int to)
{
	int t = from;
	for (;;){
		if (to == t) break;
		swap(s[t], s[t - 1]);
		t--;
	}
}
int main()
{

	int k;
	int curr = 0;
	int tk;
	char tmax = 0;
	cin >> s >> k;
	while (k &&  curr<s.size())
	{
		tmax = s[curr];
		tk = curr;
		for (int i = curr; i <= min(curr + k,(int)s.size()); i++)
		{
			if (tmax == '9') break;
			if (s[i]>tmax){
				tmax = s[i];
				tk = i;
			}
		}
		k -= (tk - curr);
		for (;;){
			if (curr > tk-1) break;
			swap(s[tk], s[tk - 1]);
			tk--;
		}
		curr++;
		//	cout <<k<<" " << s << endl;
	}
	cout << s << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
string a;int i,j,l,y,mx,k;
int main()
{
    cin>>a>>k;
    for(i=0;i<a.size();i++)
    {mx=a[i];y=-1;
        for(j=i+1;j<a.size();j++)
        {
            if(mx<a[j]&&k>=j-i)
            {
                mx=a[j];
                y=j;
            }
        }
        if(y!=-1)
        {
            for(l=y;l>i;l--)
                swap(a[l],a[l-1]);
            k-=y-i;
        }
    }
    cout<<a;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    int k,length,best;
    char mx,temp;
    string z;
    cin>>z>>k;
    length=z.length();
    for(int i=0;i<length-1;i++)
    {
        mx=z[i];
        best=-1;
        //cout<<min(i+k+1,length-1)<<"\n";
        for(int j=i+1;j<min(i+k+1,length);j++)
        {
            //cout<<mx<<" "<<z[j]<<"\n";
            if(z[j]>mx)
            {
                mx=z[j];
                best=j;
            }
        }
        //cout<<i<<" "<<mx<<" "<<best<<"\n";
        if(best!=-1)
        {
            k-=(best-i);
            for(int j=best;j>i;j--)
            {
                temp=z[j];
                z[j]=z[j-1];
                z[j-1]=temp;
            }
        }
    }
    cout<<z;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <set>
#include <deque>
#include <fstream>

using namespace std;

#define forn(i,n) for (int i = int(0); i < int(n); i++)
#define forb(i,n) for (int i = int(n-1); i >= int(0); i--)
#define for1(i,n) for (int i = int(1); i <= int(n); i++)
#define fore(i,a,n) for (int i = int(a); i < int(n); i++)

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int base = 1e9;
const int maxn = 25;
const int MAXN = 5500;
const int logn = 20;
const int inf = 2e9;
const int alpha = 26;
const int my_hash = 29;
const int my_mod = 2495828519;
const long long l_inf = 4e18;
const long long mod = 1e9+7;
const double pi = acos(-1.0);
const double eps = 1e-9;

int main() {
	string a;
	int k, pos = 0;
	cin >> a >> k;
	while (pos < a.sz - 1 && k > 0) {
		char mx = 0, p = -1;
		for (int i = pos; i < min((int) a.sz, pos + k + 1); i++) {
			if (a[i] > a[pos] && a[i] > mx) {
				mx = a[i];
				p = i;
			}
		}
		pos++;
		if (p == -1) continue;
		for (int i = p; i >= pos; i--)
			swap(a[i], a[i - 1]);
		k -= p - pos + 1;
	}
	cout << a;
}

#include <bits/stdc++.h>
using namespace std;

char tmp[100000];
int a[100000];

int main() {
    char c=getchar();int n=0;
    while (c<'0'||c>'9')c=getchar();
    while (c>='0'&&c<='9')a[++n]=c-'0',c=getchar();
    int k;
	scanf("%d",&k);
    for (int i=1;i<=n;++i) {
        int pos=i;
        int E=min(i+k,n);
        for(int j=i+1;j<=E;++j)
        if(a[j]>a[pos])pos=j;
        if(pos==i)continue;
        for(int j=pos;j>i;j--)swap(a[j],a[j-1]);
        k-=(pos-i);
		if(k==0)break;
    }
    for (int i=1;i<=n;i++)putchar(a[i]+'0');
	putchar('\n');
    return 0;
}

#include<cstdio>
#include<cstring>
using namespace std;
char s[22];
int main()
{
    int n,i,step,t,ns,st,maxn;
    char max,temp;
    while(scanf("%s%d",s,&n)!=EOF)
    {
        ns=strlen(s);
        step=n;
        st=0;
        while(step)
        {
            max='0';
            for(i=st;i<=st+step&&i<ns;i++)
                if(s[i]>max)
                {
                    maxn=i;
                    max=s[i];
                }
            if(max==s[st])
            {
                st++;
                continue;
            }
            if(max>s[st])
            {
                for(i=maxn;i>st;i--)
                {
                    temp=s[i];
                    s[i]=s[i-1];
                    s[i-1]=temp;
                }
                step-=(maxn-st);
                st++;
            }
            else
            {
                break;
            }
        }
        printf("%s\n",s);
    }
    return 0;
}

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>

using namespace std;

void make_swap(string& s, int i, int j) {
	s.insert(i, 1, s[j]);
	s.erase(s.begin() + j + 1);
}

int main() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		int mx = i;
		for (int j = i; j <= i + k && j < n; j++)
			if (s[j] > s[mx])
				mx = j;
		k -= (mx - i);
		make_swap(s, i, mx);
	}
	cout << s << endl;
	return 0;
}

/*
    __  __
   |  \/  |
   | \  / | ___  ___  ___  ___
   | |\/| |/ _ \/ __|/ _ \/ __|
   | |  | | (_) \__ \  __/\__ \
   |_|  |_|\___/|___/\___||___/

*/

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/* GEOMETRY START

const double PI  = acos(-1.0);
const double EPS = 1e-10;
typedef complex<double> point;

#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
//#define polar(r,ang)            ((r)*exp(point(0,ang)))  ==> Already added in c++11
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))

int dcmp(double a,double b)
{
	return fabs(a-b) < EPS ? 0 : a < b ? -1 : 1;
}

point reflect(point p, point p0, point p1) {
    point z = p-p0, w = p1-p0;
    return conj(z/w)*w + p0; // Refelect point p around p0p1
}

double fixAngle(double A) {
	return A > 1 ? 1 : (A < -1 ? -1 : A);
}

// return min angle: aOb / bOa
// dp(v1, v2) = |v1|*|v2|*cos(theta)
double angleO(point a, point O, point b) {
  point v1(a - O), v2(b - O);
  return acos( fixAngle ( dp(v1, v2) / length(v1) / length(v2) ) );
}

double getAng(point &a, point &b, point &c) // find angle abc, anticlock bc to ba
{
    double ang = angle( vec(b, c)) - angle( vec(b, a));
    if(dcmp(ang, 0) < 0)
    	ang+=2*PI;
    return ang;
}

bool isCollinear(point a, point b, point c) {
	return fabs( cp(b-a, c-a) ) < EPS;
}

bool isPointOnRay(point p0, point p1, point p2) {
    if(length(p2-p0) < EPS) return true;
    return same( normalize(p1-p0), normalize(p2-p0) );
}

bool isPointOnSegment(point a, point b, point c) {
	return isPointOnRay(a, b, c) && isPointOnRay(b, a, c);
}

double distToLine( point p0, point p1, point p2 ) {
	return fabs(cp(p1-p0, p2-p0)/length(p0-p1)); // area = 0.5*b*h
}

//distance from point p2 to segment p0-p1
double distToSegment( point p0, point p1, point p2 ) {
	double d1, d2;
	point v1 = p1-p0, v2 = p2-p0;
	if( (d1 = dp(v1, v2) ) <= 0)	return length(p2-p0);
	if( (d2 = dp(v1, v1) ) <= d1)	return length(p2-p1);
	double t = d1/d2;
	return length(p2 - (p0 + v1*t) );
}

 GEOMETRY END */

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+9;
const int N = 1e5+7;

int main()
{
	vector<pair<int,int> > vec;
	string ss;
	int k;
	cin >> ss >> k;
	int n = ss.size();
	rep(i,n)
	{
		vec.pb({ss[i]-'0',-i});
	}

	sort(vec.rbegin(),vec.rend());
	int last = 0;
	rep(i,n)
	{
		if (-vec[i].s <= k) {k+= vec[i].s;cout << vec[i].f;ss.erase(-vec[i].s,1);}
		else break;
		repA(j,i+1,n-1) if (-vec[i].s < -vec[j].s) vec[j].s++;
		last++;
	}
	//n = ss.size();
	repA(i,last,n-1)
	{
		char c = ss[0];
		int tmp = 0;
		repA(j,1,(int)ss.size()-1)
		{
			if (ss[j] > c && j <= k) {c = ss[j];tmp = j;}
		}
		k -= tmp;
		cout << c;
		ss.erase(tmp,1);
	}
	cout << '\n';

    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
    char str[20];
    int k;
    cin >> str >> k;
    int n = strlen(str);
    for(int i = 0;i < n && k > 0;i++){
        int p = i;
        int max = str[i];
        for(int j = i;j < n && j <= i + k;j++){
            if(str[j] > max){
                p = j;
                max = str[j];
            }
        }
        k -= p - i;
       for(int j = p;j > i;j--){
            str[j] = str[j - 1];
       }
       str[i] = max;
    }
    cout << str << endl;
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

#define PB push_back
#define MP make_pair
#define AA first
#define BB second
#define SZ size()
#define BG begin()
#define OP begin()
#define ED end()
#define SQ(x) ((x)*(x))
#define cmax(x, y) x = max(x, y)
#define cmin(x, y) x = min(x, y)

const double eps = 1e-8;
const LL MOD = 1000000007;
typedef pair<LL, int> PLI;
LL org, e[30], ans;
char in[30];
int k, len;

void gao(int h) {
//    cout << "h: " << h << " " << org << " " << k << endl;
    LL o = org;
    LL dmax = o;
    int p = -1;
    int step = 0;
    for(int i = 2; i <= len; i++) {
        int he = max(1, i - k);
        LL t = org;
        int c = 0;
        for(int j = i - 1; j >= he; j--) {
            int ii = ( t % e[j - 1] ) / e[j];
            int jj = ( t % e[j] ) / e[j + 1];
            LL tt = t - ii * e[j] - jj * e[ j + 1] + ii * e[j + 1] + jj * e[j];
            if(tt > t) {
                c++;
                t = tt;
            }
            else break;
        }
//        cout << o << " " << he << " " << i << " " << t << endl;
        if(dmax < t) {
            dmax = t;
            p = i;
            step = c;
        }
    }
    if(p == -1) {
        k = 0;
    }
    else {
//        cout << "dmax: " << dmax << " " << step << endl;
        k -= step;
        org = dmax;
        cmax(ans, org);
    }
}

int main() {
    int i, j;
//    freopen("input.txt", "r", stdin);
    //freopen("", "w", stdout);
    scanf("%s%d", in, &k);
    len = strlen(in);
    e[len] = 1;
    for(i = len - 1; i >= 0; i--) {
        e[i] = e[i + 1] * 10;
    }
    org = 0;
    for(i = 1; i <= len; i++) org = org * 10 + in[i-1] - '0';
    ans = org;
    for(int step = 1; k > 0; step++) {
        gao(step);
    }
    printf("%I64d\n", ans);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int K;
char num[20];
set<pair<pair<int, int>, pair<int, int>>> s;

int main()
{
    //freopen("in.txt", "r", stdin);
    int N=0;
    while((num[N]=getchar())>='0')
        N++;
    num[N]='\0';
    scanf("%d", &K);
    for(int i=0; i<N; i++)
    {
        pair<char, int> maxi=make_pair(num[i], 0);
        for(int j=i+1; j<N; j++)
            if(j-i<=K)
                maxi=max(maxi, make_pair(num[j], i-j));
        if(maxi.second)
        {
            K+=maxi.second;
            for(int j=-maxi.second-1; j>=0; j--)
                swap(num[i+j], num[i+j+1]);
        }
    }
    for(int i=0; i<N; i++)
    {
        int j=i;
        while(j>0 && num[j]>num[j-1] && K>0)
        {
            swap(num[j], num[j-1]);
            j--;
            K--;
        }
    }
    puts(num);
    return 0;
}

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);
using namespace std;
const int INF = 1<<30;
int main()
{
    IOS
    ///freopen("out.txt","w",stdout);
    string ss;
    int k,i=0;
    cin>>ss>>k;
    while(k>0&&i<ss.size())
    {
        int maxi=-INF,j,lim=i+k;
        if(lim>ss.size()){lim=ss.size();}
        for(int m=i+1;m<=lim;++m)
        {
            if(ss[m]-48>maxi){maxi=ss[m]-48; j=m;}
        }
        ///cout<<maxi<<" "<<j<<endl;
        if(maxi>ss[i]-48)
        {
            for(int m=j-1;m>=i;--m)
            {
                swap(ss[m],ss[m+1]);
            }
            k-=j-i;
        }
        ++i;
    }
    cout<<ss<<endl;
}
/// This code is less virgin than me

#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);
const ll mod=1e9+7;

/*struct point{
  long long int k,l,rat;
} p[1000000];*/
/*bool com(point l, point r)
{
    return l.rat>r.rat;
}*/
struct Interval
{
    int start, end;
};
bool compareInterval(Interval i1, Interval i2)
{
    return (i1.start < i2.start);
}
using namespace std;
int main(){
	ios
   /*ll t;
   cin>>t;
   while(t--)
   {*/
	string s;
	cin>>s;
	int k;
	cin>>k;
	if(k==0)
	{
		cout<<s<<"\n";
		return 0;
	}
	int m=0;
	int ind=0;
	bool flag=0;
	for(int i=0;i<s.length();i++)
	{
		int max=0;
		if(i+k>s.length()-1)
			m=s.length();
			else m=i+k;
		for(int j=i;j<=m;j++)
		{
			//cout<<"s[j]:"<<s[j]<<"\n";

			//int n=s[j];
			if(max<s[j])
			{
				max=(int)s[j];
				ind=j+1;
			}
		}
		//cout<<ind<<" "<<i<<"\n";
		for(int j=ind-1;j>i;j--)
		{
			swap(s[j],s[j-1]);
		}
		k=k-(ind-(i+1));

		//cout<<k<<"\n";
		//swap(s[ind-1],s[i]);
		if(k<=0)
			break;
	}
	cout<<s<<"\n";

   // }
}

#include<bits/stdc++.h>
using namespace std;

#define Inter(v, a, n, b, m) v.resize(set_intersection(a, a + (n), b, b + (m), v.begin()) - v.begin())
#define SInter(v, a, n, b, m) v.resize((n) + (m)); sort(a, a + (n)); sort(b, b + (m)); Inter(v, a, n, b, m)
#define Union(v, a, n, b, m) v.resize(set_union(a, a + (n), b, b + (m), v.begin()) - v.begin());
#define SUnion(v, a, n, b, m) v.resize((n) + (m)); sort(a, a + (n)); sort(b, b + (m)); Union(v, a, n, b, m)
#define Diff(v, a, n, b, m) v.resize(set_difference(a, a + (n), b, b + (m), v.begin()) - v.begin())
#define SDiff(v, a, n, b, m) v.resize((n) + (m)); sort(a, a + (n)); sort(b, b + (m)); Diff(v, a, n, b, m)
#define Sym(v, a, n, b, m) v.resize(set_symmetric_difference(a, a + (n), b, b + (m) v.begin()) - v.begin())
#define SSym(v, a, n, b, m) v.resize((n) + (m)); sort(a, a + (n)); sort(b, b + (m)); Sym(v, a, n, b, m)

typedef long long ll;
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
#define Uni(a) a.resize(unique(all(a)) - a.begin()) /// STL专用
#define SUni(a) sort(all(a)); Uni(a) /// STL专用
#define Cnt1(n) (__builtin_popcount(n))
#define Cntt1(n) (__builtin_popcountll(n)) /// 参数必须为ull类型
#define cb(n) (32 - __builtin_clz(n))
#define cbb(n) (64 - __builtin_clzll(n)) /// 参数必须为ull类型
#define sq(x) ((x) * (x))
#define Sqrt(n) (int)sqrt((double)(n) + 0.5)
#define mem(a, num) memset(a, num, sizeof(a))
#define cpy(to, from) memcpy(to, from, sizeof(from))
#define Rcpy(l, r, b) reverse_copy(l, r, b) /// 注意为左闭右开区间

typedef unsigned long long ull;
#define gr() greater<int>()
#define Acc(a, n) (accumulate(a, a + (n), 0))
#define uninum(a, n) (unique(a, a + (n)) - a) /// 试用前请sort
#define nth(a, k, n) nth_element(a + 0, a + k, a + n) /// *可能要事先--k
#define nthg(a, k, n) nth_element(a + 0, a + k, a + n, greater<int>()) /// *可能要事先--k
#define Min(a, n) (*min_element(a, a + (n)))
#define Max(a, n) (*max_element(a, a + (n)))
#define Minpos(a, n) (min_element(a, a + (n)) - a)
#define Maxpos(a, n) (max_element(a, a + (n)) - a)
#define Lowpos(a, n, x) (lower_bound(a, a + (n), x) - a)
#define Upppos(a, n, x) (upper_bound(a, a + (n), x) - a)
#define BS(a, n, x) binary_search(a, a + (n), x) /// 返回bool值
#define Range(a, n, x) equal_range(a, a + (n), x) /// 返回pair
#define Fpos(a, n, x) (find(a, a + (n), x) - a)

typedef vector<int>::iterator viter;
#define For(i, n) for (i = 0; i < (n); ++i)
#define Forr(i, start, n) for (i = start; i < (n); ++i)
#define Forrr(i, start, n, step) for (i = start; i < (n); i += (step))
#define rFor(i, n) for (i = (n); i >= 0; --i)
#define rForr(i, n, end) for (i = n; i >= (end); --i)
#define rForrr(i, n, end, step) for (i = n; i >= (end); i -= (step))
#define loop(a) for (it = a.begin(); it != a.end(); ++it)

typedef set<int>::iterator siter;
typedef map<int, int>::iterator miter;
#define SI(a) scanf("%d", &a)
#define SII(a, b) scanf("%d%d", &a, &b)
#define SIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SIIII(a, b, c, d) scanf("%d%d%d%d", &a, &b, &c, &d)
#define SIIIII(a, b, c, d, e) scanf("%d%d%d%d%d", &a, &b, &c, &d, &e)
#define SL(a) scanf("%lld", &a)
#define SLL(a, b) scanf("%lld%lld", &a, &b)
#define SLLL(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SLLLL(a, b, c, d) scanf("%lld%lld%lld%lld", &a, &b, &c, &d)
#define SD(a) scanf("%lf", &a)
#define SDD(a, b) scanf("%lf%lf", &a, &b)
#define SDDD(a, b, c) scanf("%lf%lf%lf", &a, &b, &c)
#define SA(a, i, n) For(i, n) scanf("%d", a + i) /// 便于扩展 *不要在后面加逗号！
#define SAA(a, i, n, j, m) For(i, n) For(j, m) SI(a[i][j]) /// *不要在后面加逗号！
#define GC(c) (c = getchar())
#define GCn() getchar()
#define UC(c) ungetc(c, stdin)
#define SS(s) scanf("%s", s)
#define SSS(s, s2) scanf("%s%s", s, s2)

typedef multiset<int>::iterator msiter;
typedef multimap<int, int>::iterator mmter;
#define PI(a) printf("%d\n", a)
#define PII(a, b) printf("%d %d\n", a, b)
#define PIII(a, b, c) printf("%d %d %d\n", a, b, c)
#define PL(a) printf("%lld\n", a)
#define PLL(a, b) printf("%lld %lld\n", a, b)
#define PLLL(a, b, c) printf("%lld %lld %lld\n", a, b, c)
#define PD(a) printf("%f\n", a)
#define PDD(a, b) printf("%f %f\n", a, b)
#define PDDD(a, b, c) printf("%f %f %f\n", a, b, c)
#define PA(a, i, n) For(i, (n) - 1) printf("%d ", a[i]); PI(a[(n) - 1]) /// 由于要支持STL的数据类型，故不用+的形式，必要时请手动改成+
#define PAA(a, i, n, j, m) For(i, n) {For(j, (m) - 1) printf("%d ", a[i][j]); PI(a[i][(m) - 1]);}
#define PAn(a, i, n) For(i, n) PI(a[i])
#define PiA(a, i, n) For(i, n) PII(i, a[i]) /// debug用
#define rPA(a, i, n) rForr(i, n - 1, 1) printf("%d ", a[i]); PI(a[0])
#define rPAn(a, i, n) rFor(i, n - 1) PI(a[i])
#define PC(c) putchar(c)
#define Pn() putchar(10)
#define Ps() putchar(32)

#define Fin(f) freopen(f, "r", stdin) /// 请手动加.in
#define Fout(f) freopen(f, "w", stdout) /// 请手动加.out
#define random(m) ((rand() << 16 | rand()) % m) /// [0,m)之间的伪随机数
#define SR() srand((unsigned)time(NULL))

typedef long double ld;
const int inf = 0x3f3f3f3f; /// 1.06e9 (INT_MAX为2.147e9)
const long long llinf = 0x3f3f3f3f3f3f3f3f; /// 4.56e18
const double pi = acos(-1.0);
//const double tens[11] = {0.0, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, 1e-10};
//double fgcd(double a, double b) {return fabs(b) > eps ? fgcd(b, fmod(a, b)) : a;}

//const int dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
//const int dirr[8][2] = {1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -1, -1, 0, -1, 1, -1};
//const int knight_dir[8][2] = {1, 2, 1, -2, -1, 2, -1, -2, 2, 1, 2, -1, -2, 1, -2, -1};

/// 不可使用如下间接保留字：rank, tm,time, write, j0,j1,jn,y0,y1,yn
/// 如果用gets(s), GC(ch)读入WA的话，请用SS(s), scanf(" %c ", &ch)代替
/// 在main()中大量初始化STL类型容易死机
/// 注意strncpy不会加尾0，请手动添加
/// 相对位置不变的排序stable_sort(a, a + n);
/// C++会帮你往上类型转换，但G++不会
/*G++扩栈
int __size__ = 256 << 20; // 256MB
char *__p__ = (char*)malloc(__size__) + __size__;
__asm__("movl %0, %%esp\n" :: "r"(__p__));
*/

typedef pair<int, int> p2; /// 赋值时直接SII(a[i].x, a[i].y)就行, 有时候用ll
typedef pair<pair<int, int>, int> p3;
typedef pair<int, pair<int, int> > pi3;
//#define x first
//#define y second
//#define MT(a, b, c) make_pair(make_pair(a, b), c)

//const double eps = 1e-8;
//const int mod = int(1e9) + 7;
#define Pcas() printf("Case #%d: ", ++cas) /// 请仔细对照
const int mx = 105;

char ch[111];
int k;

int main() {
    scanf("%s", ch);
    scanf("%d", &k);
    int len = strlen(ch);
    for (int i = 1; i <= len && k > 0; i++) {
        int tmp = min(k, len - i);
        int tem = i;
        for (int j = i; j <= i + tmp; j++) {
            if (ch[j-1] > ch[tem-1]) {
                tem = j;
            }
        }
        for (int j = tem; j > i; j--) {
            swap(ch[j-1], ch[j-2]);
            k--;
        }
    }
    printf("%s", ch);
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
//struct node
//{
//	int val,pos;
//}b[101];
char a[101];
int main()
{
	cin>>a;
	int k,pos;
	scanf("%d",&k);
	for(int i = 0; a[i] != '\0'; i++)
	{
		int maxx = a[i] - 48,pos = i;
		for(int j = i + 1; j <= i + k; j++)
		{
			int p = a[j] - 48;
			if(p > maxx)
			{
				maxx = p;
				pos = j;
			}
			//cout<<2;
		}
		for(int j = pos; j != i; j--,k--)
		{
			swap(a[j - 1],a[j]);
			//cout<<1;
		}
	}
	for(int i = 0; a[i] != '\0'; i++)
	{
		cout<<a[i];
	}
	return 0;
}

#include <iostream>
#include <limits.h>
#include <cstdio>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

char arr [100];
char arr2[100] ;

int main()
{
    int k;
    int c =0;

    for(int i = 0; arr[i-1]!=' ' ; i++)
    {
        scanf("%c",&arr[i]);
        arr2[i]=arr[i];
        c++;
        if(arr[i] ==' ')
            break;
    }
    cin >> k;
    int j = 0;
    int endd =0;
    sort(arr2, arr2+c-1);
    while(k && j < c-1 )
    {
        char temp = CHAR_MIN ;
        int index=0 ;
        for(int i = j ; i < c -1&& k > 0 ; i++)
        {

           if(arr[i] > temp && ( i - j <= k ) )
           {
               temp = arr[i];
               index = i;
           }
        }
        bool flag= false;
        for(int i = index ; i > j && arr[i] > arr[i-1]; i--)
        {
            char v = arr[i];
            arr[i]=arr[i-1];
            arr[i-1]=v;
            k--;
            if(k==0)
                break;
        }
        int kk=c-2;
        for(int i = 0 ; i < c-1 ; i++)
        {

            if(arr2[kk]!=arr[i])
            {
                flag=false;
                break;
            }
            else
                flag=true;
            kk--;
        }
        if(flag)
            break;
        j++;
    }
    for(int i = 0 ; i < c && arr[i] != ' '; i++)
        cout << arr[i] ;
    return 0;

}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    string s;
    cin>>s>>n;
    int maxV;
    int maxI=0;
    bool chk=1;
    if (s.size()==1){
        cout<<s<<endl;
        return 0;
    }
    for(int i=0; i<s.size(); i++)
    {
        maxV=s[i];
        int x=n+i;
        if (x>s.size())
            x=s.size();
        for(int j=i; j<=x ; j++)
        {
            if (maxV<s[j])
            {
                maxV=s[j];
                maxI=j;
               chk=0;
            }
        }
        if (chk)
            continue;
        chk=1;
        n-=maxI-i;
        for(int k=maxI; k>i; k--)
            swap(s[k],s[k-1]);

    }
    cout<<s<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

int main()
{
	string a;
	int k = 0;
	cin >> a >> k;
	for (int d = 0; d < a.length(); ++d)
	{
		if (a[d] == '9')
			continue;
		int mx = a[d];
		int mxp = d;
		for (int i = d + 1; i < a.length() && i - d <= k; ++i)
		{
			if (a[i] > mx)
			{
				mx = a[i];
				mxp = i;
			}
		}
		for (int i = mxp; i > d; --i)
		{
			swap(a[i], a[i - 1]);
			--k;
		}
	}
	cout << a << endl;
	return 0;
}

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;

    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    bool c = false;
    while(n){
        if(n&1) res = res * x;

        if(res > mod){
            c = true;
            res %= mod;
        }
        x = x * x %mod;
        n >>= 1;
    }
    if(c) return mod;
    return res;
}

#define SIEVE_SIZE 5000000+10
bool sieve[SIEVE_SIZE];
void make_sieve(){
    for(int i=0; i<SIEVE_SIZE; ++i) sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for(int i=2; i*i<SIEVE_SIZE; ++i) if(sieve[i]) for(int j=2; i*j<SIEVE_SIZE; ++j) sieve[i*j] = false;
}

bool isprime(ll n){
    if(n == 0 || n == 1) return false;
    for(ll i=2; i*i<=n; ++i) if(n%i==0) return false;
    return true;
}

template<typename T>
vector<T> gauss_jordan(const vector<vector<T>>& A, const vector<T>& b){
    int n = A.size();
    vector<vector<T>> B(n, vector<T>(n+1));

    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            B[i][j] = A[i][j];
        }
    }

    for(int i=0; i<n; ++i) B[i][n] = b[i];

    for(int i=0; i<n; ++i){
        int pivot = i;
        for(int j=i; j<n; ++j){
            if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
        }
        swap(B[i], B[pivot]);

        if(abs(B[i][i]) < EPS) return vector<T>(); //解なし

        for(int j=i+1; j<=n; ++j) B[i][j] /= B[i][i];
        for(int j=0; j<n; ++j){
            if(i != j){
                for(int k=i+1; k<=n; ++k) B[j][k] -= B[i][j] * B[i][k];
            }
        }
    }

    vector<T> x(n);

    for(int i=0; i<n; ++i) x[i] = B[i][n];
    return x;

}

ll GCD(ll a, ll b){
    if(a<b) swap(a,b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
    mat C(A.size(), vec((int)B[0].size()));
    for(int i=0; i<A.size(); ++i){
        for(int k=0; k<B.size(); ++k){
            for(int j=0; j<B[0].size(); ++j){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j] %MOD) % MOD;
            }
        }
    }
    return C;
}
mat mat_pow(mat A, ll n) {
    mat B(A.size(), vec((int)A.size()));

    for(int i=0; i<A.size(); ++i){
        B[i][i] = 1;
    }

    while(n > 0) {
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

bool operator<(const pii& a, const pii& b){
    if(a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int bit[1000010];
int sum(int i){
    int s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(int i, int x){
    while(i <= 1000010){
        bit[i] += x;
        i += i & -i;
    }
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

vector<vector<int>> v(10);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    string s; int k; cin >> s >> k;

    int n = s.size();

    for(int i=0; i<n; i++){

        int idx = -1;
        char maxv = s[i];
        for(int j=i+1; j<n; j++){
            if(k >= j - i){
                if(maxv < s[j]){
                    maxv = s[j];
                    idx = j;
                }
            }
        }
        if(idx == -1) continue;
        for(int j=idx; j>i; j--){
            swap(s[j], s[j-1]);
        }

        k -= idx-i;
    }
    cout << s << endl;

    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int k;
	cin>>k;
	int a[20];
	int n=(int)s.length();
	for (int i=0; i<n; i++){
		a[i]=s[i]-'0';
	}
	if (n==1) {
		cout<<a[0];
		return 0;
	}
	int num=0;
	while (true){
		if (k==0 || num>n) {
			for (int j=0; j<n; j++)
				cout<<a[j];
			cout<<endl;
			return 0;
		}
		else {
			bool t=false;
			int num2=-1;
			int maxn=a[num];
			for (int j=num+1; j<n; j++){
				if (maxn<a[j] && (j-num)<=k) {
					t=true;
					maxn=a[j];
					num2=j;
				}
			}
			if (t==true) {
				for (int j=num2; j>num; j--)
					swap(a[j],a[j-1]);
				k-=(num2-num);
			}
			else {
				num++;
			}
		}
	}

}

#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

ll min(ll a, ll b, ll c) { return min(a, min(b, c)); }

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

struct sp{
    bool operator() (const psi &a, const psi &b){

        if (a.ss != b.ss) {

            return (a.ss > b.ss);

        }

        return (a.ff < b.ff);

    }

};

int stoi(string &str) { istringstream ss(str); int i; ss >> i;  return i; }

string itos(ll i) { stringstream ss; ss << i;   return ss.str(); }

ll numBits(ll n) { ll c = 0;   while (n){ n &= (n - 1);   c++; }  return c; }

int main(){

    string s;
    int k;
    cin >> s >> k;

    for (int i = 0; i < s.length(); i++) {

        int pos = i, mx = s[i];

        for (int j = i + 1; j < i + k + 1 && j < s.length(); j++) {

            if (s[j] > mx){

                mx = s[j];
                pos = j;

            }

        }

        for (int j = pos; j > i; j--) swap(s[j], s[j - 1]);
        k -= (pos - i);

    }

    cout << s << endl;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int findMaxIndex(string s, int start, int end)
{
	int max = start;
	for(int i=start; i<=end && i<s.length(); i++)
	{
		if(s[i] > s[max])
			max = i;
	}
	return max;
}

string changeString(string s, int ii, int ci)
{
	string s_new = s;
	for(int i=ci; i>ii; i--)
	{
		char temp = s_new[i];
		s_new[i] = s_new[i-1];
		s_new[i-1] = temp;
	}
	return s_new;
}

int main()
{
	string a;
	int k;
	cin >> a >> k;

	int i = 0;
	while(i < a.length())
	{
		int max_i = findMaxIndex(a, i, i+k);
		if(max_i != i)
		{
			a = changeString(a, i, max_i);
			k = k - (max_i-i);
		}
		i++;
	}

	cout << a << endl;

	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <stdio.h>

using namespace std;

int a[20];

int findfind(int siz, int dig)
{
	for (int i = siz; i>=0; i--)
		if (a[i] == dig) return i;
	return -1;
}

void change (int first, int last)
{
	int x = a[first];
	for (int i = first; i< last; i++)
		a[i] = a[i+1];
	a[last] = x;
}

int main()
{
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
	long long n;
	cin >> n;
	int k;
	cin >> k;
	int i =0;
	while (n != 0 )
	{
		a[i] = n % 10;
		n /= 10;
		i++;
	}
	int p = i-1;
	int kk = p;
	while (true)
	{
		int m = a[kk];
		for (i = 9; i>m; i--)
		{
			int ind = findfind(kk-1, i);
			if (ind != -1 && kk - ind <= k)
			{
				change(ind, kk);
				k -= kk-ind;
				break;
			}
		}
		kk--;
		if (kk<0) break;
		if (k == 0) break;
	}

	for (i = p; i>=0; i--)
		cout << a[i];
	return 0;

}

/*
still sad
(1,1)
*/

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
const int N = (int) 3e5 + 113;
const long long MOD = (long long)1e9 + 7;

string s;
int k, ind;

int findMin(int l, int r) {
	int ans = l;
	for (int i = l; i <= r; i++) {
		if (s[i] == s[l])
			continue;
		if (s[i] > s[ans])
			ans = i;
	}
	return ans;
}
void Swap(int l, int r) {
	for (int i = r - 1; i >= l; i--)
		swap(s[i], s[i + 1]);
}
int main() {
	//freopen("input.txt", "r", stdin);

	cin >> s >> k;
	for (int i = 0; i < s.size(); i++) {
		int ind = findMin(i, min((int)s.size() - 1, i + k));
		Swap(i, ind);
		k -= ind - i;
	}

	cout << s;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int K;
string A;
int main(){

  fastStream();
  cin>>A>>K;
  string res;
  while(K>0&&A.size()>1){
    map<char,int> m;
    for(int i=0;i<(int)A.size();i++){
      if(m.count(-A[i])==0){
        m[-A[i]]=i;
      }
    }
    for(pair<char,int> p : m){
      if(p.second<=K){
        K-=p.second;
        res+=A[p.second];
        A=A.substr(0,p.second) + A.substr(p.second+1);
        break;
      }
    }
  }

  res+=A;
  cout<<res<<endl;

  return 0;
}

#include <bits/stdc++.h>

#define ll long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    //for (int i = 0; i < k; i++)
    //{
    //    for (int j = 0; j < n - 1; j++)
    //    {
    //        if (s[j] < s[j + 1])
    //        {
    //            swap(s[j], s[j + 1]);
    //            break;
    //        }
    //    }
    //}
    int base = 0;
    while (k > 0)
    {
        int high = 0;
        int loc = -1;
        for (int i = base; i <= min(k, n) + base; i++)
        {
            if(i >= n)
            break;
            if (s[i] > high)
            {
                high = s[i];
                loc = i;
            }
        }
        if (loc >= 0)
        {
            k -= loc - base;
            //swap(s[loc], s[base]);
            for (int i = loc; i > base; i--)
            {
                swap(s[i - 1], s[i]);
            }
        }
        base++;
        if (base >= n)
            break;
    }
    cout << s << endl;
}

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long int n,s,d[10000],q,m,w,k,z;

int main()
{
	cin>>s>>n;
	while(s>0)
	{
		d[q]=s%10;
		s/=10;
		q++;
	}
	reverse(d,d+q);

	while(n>0)
	 {
	 	k=0;
	 	for(int i=z;i<=n+z;i++)
	 	{
		 	 if(d[i]>k)
		 	 {
			 	k=d[i];
				w=i;
			 }
		}
		if(k>d[z])
		 {
		 	for(int i=w;i>z;i--)
		 	 swap(d[i],d[i-1]);
		 	n-=(w-z);
		 }
		if(z==q)
		 break;
		z++;
	 }
	for(int i=0;i<q;i++)
	 cout<<d[i];
	cout<<endl;

 	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char str[200];
int nt;

int main()
{
    long long int a;
    int k;
    cin>>a>>k;
    while(a)
    {
        str[nt++]=a%(10LL)+'0';
        a/=10LL;
    }
    for(int i=nt-1;i>=0&&k;i--)
    {
        int mark=-1,dist=-1;
        for(int j=i;j>=max(0,i-k);j--)
        {
            if(str[j]>str[mark])
            {
                mark=j; dist=i-j;
            }
        }
        k-=dist;
        for(int j=mark;j<i;j++)
        {
            swap(str[j],str[j+1]);
        }
    }
    for(int i=nt-1;i>=0;i--)
    {
        cout<<str[i];
    }
    cout<<endl;
    return 0;
}

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);
using namespace std;
const int INF = 1<<30;
int main()
{
    IOS
    ///freopen("out.txt","w",stdout);
    string ss;
    int k,i=0;
    cin>>ss>>k;
    while(k>0&&i<ss.size())
    {
        int maxi=-INF,j,lim=i+k;
        if(lim>ss.size()){lim=ss.size();}
        for(int m=i+1;m<=lim;++m)
        {
            if(ss[m]-48>maxi){maxi=ss[m]-48; j=m;}
        }
        ///cout<<maxi<<" "<<j<<endl;
        if(maxi>ss[i]-48)
        {
            for(int m=j-1;m>=i;--m)
            {
                swap(ss[m],ss[m+1]);
            }
            k-=j-i;
        }
        ++i;
    }
    cout<<ss<<endl;
}
/// This code is less virgin than me

#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long int lld;
typedef long double Lf;
typedef unsigned long long int llu;

#define sz(a)                        int((a).size())
#define pb                           push_back
#define mp                           make_pair
#define F                            first
#define S                            second
#define present(c,x)                 ((c).find(x) != (c).end())
#define cpresent(c,x)                (find(all(c),x) != (c).end())
#define si(n)                        inp(n)
#define sl(n)                        scanf("%lld",&n)
#define sf(n)                        scanf("%f",&n)
#define sd(n)                        scanf("%lf",&n)
#define ss(n)                        scanf("%s",n)
#define sii(n,m)		     inp(n);inp(m)
#define siii(n,m,r)		     inp(n);inp(m);inp(r)

#define abs(x)                       ((x)<0?-(x):(x))
#define fill(a,v)                    memset((a),(v),sizeof (a))
#define INF                          INT_MAX
#define LINF                         (long long)1e18
#define EPS                          1e-9
#define MODBY 1000000007

/*int p[1000011];
VI prms;
void sieve(int n)
{int i,j;prms.pb(2);;fi(i,3,n){if(!i%2||!p[i])continue;prms.pb(i);for(j=2*i;j<n;j+=i)p[j]=1;}}*/

inline void inp( int &n )
{
n=0;
int ch=getchar();int sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}

while( ch >= '0' && ch <= '9' )
n = (n<<3)+(n<<1) + ch-'0', ch=getchar();
n=n*sign;
}

int main()
{
	int k,n;
	char a[100];
	ss(a);
	si(k);
	n = strlen(a);
	int j=0;
	for(int i=0;i<n && k>0;i++)
	{
		int u=0,x,y,mx=a[i];
		for(j=i;j<=i+k && j<n;j++)
		{
			if(a[j]>mx)
			{
				u=j-i;
				x=j;y=i;
				mx=a[j];
			}
		}
		k=k-u;
		if(u && k>=0)
		{
			for(int p=x;p>y && p>0;p--)
				swap(a[p],a[p-1]);
		}
		if(k<0)
			k+=u;
	}
	printf("%s\n",a);
	return 0;
}

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	string a;
	int k;
	cin >> a >> k;
	for(int i = 0; i<a.length()-1 && k>0; i++)
	{
		char localmax = '0'; int pos=0;
		for(int j = i; j<=i+k && j<a.length(); j++)
		{
			if(a[j]>localmax)
			{
				localmax = a[j];
				pos = j;
			}
		}
		for(int j=pos;j>i;j--)
		{
			char temp = a[j];
			a[j] = a[j-1];
			a[j-1] = temp;
		}
		if(pos>=i)
		k -= pos-i;
	}
	cout << a;
	return 0;
}

#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <cstring>
#include <map>
using namespace std;
#define LL long long
#define ULL unsigned long long
//#define REP(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define maxn 111
#define INF (1LL)<<62
#define mset(a) memset(a,0,sizeof a)
#define FR(a) freopen(a,"r",stdin)
#define FW(a) freopen(a,"w",stdout)
const int MOD=10000007 ;
int solve(char s[],int k)
{
    int len=strlen(s);
    if(len==0) return k;
    char maxx=47;
    int maxi=-1;
    REP(i,0,len-1)
    {
        if(s[i]>maxx){maxx=s[i];maxi=i;}
    }
    if(k>=maxi){
        printf("%c",s[maxi]);
        REP(i,maxi,len-2)
            s[i]=s[i+1];
        s[len-1]='\0';
        return k-maxi;
    }
    else{
        char s1[22];
        strcpy(s1,s);
        s1[maxi]='\0';
        int ii=0;
        char s2[22];
        REP(i,maxi,len-1)
            s2[ii++]=s[i];
        s2[ii]='\0';
        int xk=solve(s1,k);
        strcat(s1,s2);
        strcpy(s,s1);
        return xk;
        }

}

int main()
{
    char a[22];
    int k;
    while (~scanf("%s%d",&a,&k))
    {
        int n=strlen(a);
        while(n)
        {
            k=solve(a,k);
            n=strlen(a);
        }
        puts("");
    }
}

	#include <iostream>
	#include <algorithm>
	#include<string>
	using namespace std;

	int main() {
		string s;cin>>s;
	   int i=0,j,indx=0,mn,k,prev;cin>>k;
		char c;
		while(k)
		{
		    mn=s.size();
		    if(k+i<s.size())mn=k+i;
		    prev=s[i];
			for(j=i+1;j<=mn;j++)
			{
				if(s[j]>prev){prev=s[j];indx=j;}
				if(k-(j-i)<=0)break;
			}
			if(indx)
            {
             k-=(indx-i);
			c=s[indx];
			s.erase(s.begin()+indx);
			s.insert(s.begin()+i,c);
            }
			indx=0;
			i++;
			if(i==s.size())break;
			prev=-1;
		}
		return cout<<s,0;
	}

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)

using namespace std;
int K;
string s;
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> s >> K;
	int index = 0;
	while (K >= 0 && index <= s.size() - 1)
	{
		int max_index = index;
		rep1(i, K)
		if (index + i <= s.size())
			if (s[max_index] < s[index+i])
				max_index = index + i;

		for (int i = max_index - 1; i >= index; i--)
			swap(s[i], s[i+1]);

		K -= max_index - index;
		index ++;
	}
	cout << s << endl;
}

#include <bits/stdc++.h>
using namespace std;

#define 	mapi		map<int,int>
#define 	mapb		map<int,bool>
#define		pii			pair<int,int>
#define		vi			vector<int>
#define		mp			make_pair
#define		pb			push_back
#define		X			first
#define		Y			second
#define		ill			int long long

int main()
{
	int k,index;
	string mystr;
	char maxchar, temp;
	cin>>mystr>>k;
	for(int i=0;i<mystr.size() && k>0;i++){
		maxchar = mystr[i]; index = i;
		for(int j=i+1;j<mystr.size() && j-i<=k;j++){
			if(mystr[j]>maxchar){
				index = j;
				maxchar = mystr[j];
			}
		}
		for(int t=index-1;t>=i;t--){
			temp = mystr[t+1];
			mystr[t+1] = mystr[t];
			mystr[t] = temp;
		}
		k -= index-i;
	}
	cout<<mystr<<endl;
	return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

void gn(INT &x){

	char c;

	while(c=getchar(),c<'0'||c>'9');

	for(x=0;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());

}

char s[30];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int k,mx,ed;

	scanf("%s %d",s,&k);

	int n=strlen(s);

	for(int i=0;i<n;i++){

		mx=0;

		ed=0;

		for(int j=i+1;j<n;j++){

			if(s[j]-s[i]>mx&&j-i<=k){

				mx=s[j]-s[i];

				ed=j;

			}

		}

		if(!ed) continue;

		if(k==0) break;

		k-=ed-i;

		for(int j=ed;j>i;j--) swap(s[j],s[j-1]);

	}

	printf("%s",s);

	return 0;

}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define hell 1000000007

bool cmp(pair<int, int>p1, pair<int, int>p2)
{
  return p1.first>p2.first;
}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(2);

ll a, k;cin>>a>>k;
string s = to_string(a);
for(int i=0;i<s.size();i++)
{
  vector<pair<int, int>>v;
  for(int j=i+1;j<s.size();j++)
  {
    if(s[j]>s[i])
    {
      v.push_back({s[j]-'0', (j)});
    }
  }

  int val = INT_MAX;
  sort(v.begin(), v.end());
  char c = 'a';
  for(int j=0;j<v.size();j++)
  {
    //cout<<v[1].second<<"\n";
    if(v[j].second-i<=k && c!=v[j].first+'0')
    {
      val = v[j].second;c = v[j].first+'0';
    }
  }

  if(val!=INT_MAX){
    //cout<<val<<"vl"<<"\n";
    char c= s[val];
  s.erase(s.begin()+val);
  s.insert(s.begin()+i, c);
  k-=(val-i);}

}
cout<<s;

return 0;
}

#pragma warning (disable : 4996)

#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <ios>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <sstream>
#include <map>
#include <memory.h>
#include <stdio.h>
#include <cassert>
#include <string.h>
#include <math.h>

#define forn(i , n) for (int i = 0; i < n; ++i)
#define down(i, n) for (int i = n - 1; i >= 0; --i)

using namespace std;

typedef unsigned long long int u64;
typedef long long int i64;
typedef vector<i64> vint;
typedef vector<i64> vi64;
typedef pair<int, int> pint;
typedef pair<i64, i64> pi64;

#define FILE_NAME "file"
#define CONTEST "k"
#define M_PI 3.14159265358979323846

double sqr(double a)
{
    return a * a;
}

const i64 inf = 100000000000000000LL;

#define MAXN 300000
#define MODULE 1000000007
#define E  2.7182818284590452

struct Node
{
    Node()
    {
        u = 0;
    }
    int v;
    int u;
    vector<int> nbr;
};

struct Point
{
    int x, y;
    int used;
    Point()
    {
        used = 0;
    }
};

void resolve(string & s, int p, int & k)
{
    int best = s[p];
    int c = p;

        for (int j = p; j < s.length() && j - p <= k; ++j)
        {
            if (s[j] > best)
            {
                best = s[j] ;
                c = j;
            }
        }

    k -= (c - p);
    for (int i = c; i > p; --i)
    {
        s[i] = s[i - 1];
    }
    s[p] = best;
}

int main()
{
    clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    srand(13);
#ifdef FILE_INPUT
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif
    string a;
    int k;
    cin >> a >> k;
    int l = a.length();
    forn(i, l)
    {
        resolve(a, i, k);
    }
    cout << a;
    return 0;
}

/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    ll a, k;
    cin >> a >> k;

    str s = "";
    while(a) {
	s += a % 10 + '0';
	a/=10;
    }
    reverse(all(s));
    ll n = s.length();
    for (int i = 0; i < n; ++i) {
	if (k <= 0) break;

	int ma = 0, in = -1;
	for (int j = i + 1; j < n; ++j) {
	    if (s[j] - '0' > ma && j - i <= k) {
		ma = s[j] - '0';
		in = j;
	    }
	}
	debug(in, k, s, i);
	if (ma <= s[i] - '0') continue;
	if (in == -1) continue;
	for (int j = in; j > i; --j) {
	    swap(s[j], s[j - 1]);
	}
	k-= (in - i);
	if (k <= 0) break;
    }
    cout << s << '\n';
    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <limits>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

string number;
int k = 0, f = 1, maxi;

int main()
{
    cin >> number >> k;
    while(k != 0 && f)
    {
        f = 0;
        for(int i = 0; i < number.length() && !f; ++i)
        {
            maxi = i;
            for(int j = i + 1; j <= i + k && j < number.length(); ++j)
            {
                if(number[maxi] < number[j])
                {
                    maxi = j;
                    f = 1;
                }
            }
            if(f)
            {
                //cout << i << " " << maxi << " " << number[maxi] << endl;
                for(int j = maxi; j > i; --j)
                    swap(number[j], number[j - 1]);
                //cout << number << endl;
                k -= maxi - i;
                break;
            }
        }
    }
    cout << number;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define ff first
#define ss second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
#define d(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define IO ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define mem(a, b) memset(a,b,sizeof(a))

int main()
{
    string s; int k;
    cin >> s >> k;
    int n = s.size();
    for(int i = 0, pos; i < n-1; i++)
    {
        pos = i;
        char a = s[i];
        for(int j = i+1; j-i <= k && j < n; j++)
        {
            if(a < s[j] && pos < j)
            {
                pos = j;
                a = s[j];
            }
        }
        while(pos != i)
        {
            swap(s[pos], s[pos-1]);
            pos--;
            k--;
        }
    }
    cout << s << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long l1;

int main()
{
    l1 n,k,i,j,d,p;
    char ch[100];
    cin>>n>>k;
    stringstream s;
    s<<n;
    s>>ch;
    l1 l=strlen(ch);
    for(i=0;i<l;i++)
    {
        char max='0';
        if(i+k>=l)d=l;
        else d=k+1+i;
        for(j=i;j<d;j++)
        {
           if(ch[j]>max){
            max=ch[j];
            p=j;
           }
        }
        if(ch[i]!=max)
        {
           for(j=p;j>i;j--) ch[j]=ch[j-1];
           ch[i]=max;
           k-=(p-i);
        }
        //cout<<k<<endl;
        if(k==0)break;
    }
    cout<<ch<<endl;
    return 0;
}

#include<iostream>
#include<iomanip>
#include <functional>
#include <algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<list>
#include <string>
#include<math.h>

using namespace std ;

typedef long long ll ;
typedef vector<int> vi;
typedef vector<string> vs;

// int x = string
// stoi(string as number) ;
/*
	int -> char
	simply add '0' to int
	//char c = m + '0' ;
	//s+= c ;
*/

/*
	Reverse Element
	reverse(a + L, a + R + 1);
*/

#define fx(n) fixed<<setprecision(n)
#define OO 1e3
#define NOO -1e3
#define pii pair<int,int>
#define pid pair<int,double>
#define pll pair<long long,long long>
#define mp make_pair
#define forn(i, a) for (int i = 0;i < a;i++)

//char a[52][52] ;
//bool vis[52] ;
/*void memset(int n,int m)
{
	for ( int i = 1; i <= n; i++ )
		for ( int j = 1; j <= m; j++ )
			matrixA[i][j] = -1 ;
}*/
/*
void dfs(int node ,vector<vector<int>>& v)
{
	vis[node] = true ;
	for ( int i = 0 ; i < v[node].size() ; i++ ) {
		if ( !vis[v[node][i]] ) {
			cn++;
			dfs(v[node][i],v);
		}
	}
}*/

bool comp ( pll p1 , pll p2 ) {
	if ( p1.first == p2.first ) {
		return (p1.second < p2.second );
	}
	else
		return (p1.first > p2.first) ;

}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
	int k ;

	string s ;
	cin >> s ;
	cin >> k;
	for ( int i = 0 ; i < s.size() && k > 0 ; i++ ) {
		int max = 0 , idx = i ;
		for ( int j = i+1 ; j < s.size() && j <= k+i ; j++ ) {
			if ( s[idx] < s[j] ) {
				max = s[j] - '0' , idx = j ;
			}
		}

		for ( int j = idx ; j > i ; j-- ) {
			swap(s[j] , s[j-1] ) ;
			k-- ;
		}
	}
	cout << s << endl;

	return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    int count = 0, i = 0,p;
    while (count< k&&i<n){
        p = i;
        int t = s[i];
        for (int j = i; j <min(n-1,i+ k - count); j++)
        if (t< s[j + 1]){
            p = j + 1;
            t = s[j + 1];
        }

        for (int j = min(n-1,p); j>i; j--)
            swap(s[j], s[j - 1]);
        count += p - i;
        i++;

    }
    for (int i = 0; i < n; i++){
        cout << s[i] - '0';
    }
    cin >> n;
}

#include <bits/stdc++.h>
using namespace std ;

typedef long long ll; ///NOTES:int64
typedef vector<int> vi;

const double eps = 1e-11; ///NOTES:eps
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const double pi = acos(-1.0); ///NOTES:pi
const int MAX = 1000000000 ; /// 10^9

#define SZ(x)           (int)x.size()
#define ALL(x)          (x).begin(),(x).end()
#define ALLR(x)         (x).rbegin(),(x).rend()
#define PB( x )         push_back(x)
#define MP(x , y)           make_pair(x,y)
#define rep(i,st,en) for(int i=st ; i< en; i++)
#define repR(i,st,en) for(int i=st;i>=en ; i--)

class
Over9000Rocks
{
public :

};

int main()
{
 /// freopen("input.txt" , "rt",stdin);
///  freopen("output.txt", "wt", stdout);
string s ;
int k ;

cin >> s >> k ;

rep(i,0,SZ(s)-1)
{

    int ind = -1 ;
    char mx = '0' ;

    mx--;

    int cnt=0;

    for(int j=i+1 ; j<SZ(s)&& cnt<k ; j++)
    {
       cnt++;
       if(s[j] > mx)
       {
           mx = s[j];
           ind = j ;
       }
    }

    if(s[i] < mx)
    {
        k -= (ind-i);
        for(int j=ind ; j > i ; j--)
        {
            swap(s[j],s[j-1]);
        }
    }
}

cout << s << endl ;

return 0;
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <stack>
#include <functional>
#include <fstream>
#include <deque>
#include <queue>
#include <iostream>
#include <fstream>
#include <ctime>
#include <sstream>
#include <climits>

#define N 100003
#define PI 3.1415926535
#define EPS 0.00000001
#define MAX 1e9
#define MIN -(1e9)
#define ll long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fori(i,n) for(int (i) = 0; (i) < n; ++(i))
#define forin(i, n) for(int (i) = n-1; i >= 0; --(i))
#define mp(a, b) make_pair(a, b)
#define MOD 1000000007

using namespace std;

ll a[1234567];

int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    int m;
    cin >> m;

    for(int i = 0; i < s.size(); ++i)
    {
        ++a[s[i] - '0'];
    }

    int size = s.size();
    for(int i = 0; i < size; ++i)
    {
        if(s[i] == '9')
            continue;
        if(m >= size - i - 1)
        {
            int z = 0;
            int max = -1;
            int j = i;
            for(j; j < size; ++j)
                if(s[j]-'0' > max)
                {
                    z = j;
                    max = s[j] -'0';
                }
                for(z = z-1; z >= i && z >= 0; --z)
                    if(z < size - 1 && z >= 0)
                    {
                        swap(s[z], s[z+1]);
                        --m;
                    }
        }
        else
        {
            int max = -1;
            int j = i;
            int z = 0;
            for(j; j < i + m + 1 && j < size; ++j)
                if(s[j]-'0' > max)
                {
                    z = j;
                    max = s[j] -'0';
                }
                for(z = z-1; z >= i && z >= 0; --z)
                    if(z < size - 1 && z >= 0)
                    {
                        swap(s[z], s[z+1]);
                        --m;
                    }
        }
    }

    cout << s;

    //system("pause");
    return 0;
}

/*
1 5 17
-4 0 4 0
-6 2
5 4
6 3
7 2
8 1
*/

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main()
{

  string a;
  int k;
   int swapIndex = 0;
   int otherSwapIndex =-1;
   int maxToSwap = -1;

  int valueIndex = -1;
  int max =10;
  cin>> a >> k;
  while(true){
      if ( k == 0)
      {
          break;
      }

      for(int i = swapIndex ; i<a.size();i++){
          int num = a[i] - '0';
          if(num != 9 && num < max){
              swapIndex = i;
              valueIndex = num;
              break;
          }
      }
      if (valueIndex != -1){
          for(int i= swapIndex + 1 ; i<a.size();i++){
               int num = a[i] - '0';
               if(num > valueIndex && num > maxToSwap && i - swapIndex <= k ) {
                   otherSwapIndex = i;
                   maxToSwap = num;

               }
               if ( i - swapIndex == k){
                   break;
               }
          }
          if (otherSwapIndex == -1 && k!=0){
              if (swapIndex == a.size()-1)
              break;
              swapIndex++;

              continue;
          }
          else {
              for(int i=otherSwapIndex; i>swapIndex;i--)
            swap(a[i], a[i-1]);
            k = k - ( otherSwapIndex - swapIndex);
              otherSwapIndex =-1;
              maxToSwap = -1;
              valueIndex = -1;
              max =10;
          }

      }

  }

cout<<a<<endl;
    return 0;
}

  #pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;

  void solve(){
	  string s;
	  int k;
	  cin >> s >> k;
	  int n = s.size();
	  string k1 = s;
	  sort(all(k1));
	  reverse(all(k1));

	  for(int i=0;i<n;i++){
	  	  	if(k==0)break;
			int mx = s[i];
			int mx_indx = -1;
			for(int j=i+1;j<=min(n-1,i+k);j++){
				if(mx < s[j]){
					mx = s[j];
					mx_indx = j;
				}
			}
			if(mx_indx!=-1){
				for(int j = mx_indx;j>i;j--){
					swap(s[j-1],s[j]);
					k--;
				}
			}
		}
	  cout << s;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define dbg(x) { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 5e5+5;

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    IOS;

    string s;
    int k;
    cin >> s >> k;
    for (int i = 0; i < s.length(); ++i)
    {
    	char mx = s[i];
    	int id = i;
    	for (int j = i+1; j < min(i+k+1,(int)s.length()); j++) {
    		if(s[j]>mx) {
    			mx = s[j];
    			id = j;
    		}
    	}
    	k -= id-i;
    	for (int j = id; j >i; j--) {
    		swap(s[j],s[j-1]);
    	}
    }
    cout << s;
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	int m,n,i,j;
	char s[20];
	while(scanf("%s%d",s,&n)!=-1)
	{
		int max,maxn,st=0;
		while(n)
		{
			max=-9999999;
			for(i=st;i<=st+n&&s[i];i++)
			{
				if(max<s[i]-'0')
				{max=s[i]-'0';maxn=i;}
			}
			if(max+'0'==s[st])
			{
				st++;
				continue;
			}
			else if(max+'0'>s[st])
			{
			for(i=maxn;i>st;i--)
			{
				char c=s[i];
				s[i]=s[i-1];
				s[i-1]=c;
			}
			n=n-(maxn-st);
			st++;
			}
			else break;
		}
		printf("%s\n",s);
	}
	return 0;
}

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    string str;
    int k,x=0,i,y=0,idx;
    cin>>str;
    cin>>k;
      for(i=0;i<str.length();i++)
      {
          char ch=str[i];
          x=1;
          while(x<=k && (x+i)<str.length())
          {
              if((str[x+i]+'0')>(ch+'0'))
              {
                  idx=x+i;
                  ch=str[x+i];
              }
              x++;
          }
         if((ch+'0')!=(str[i]+'0'))
         {
             k=k-(idx-i);
             for(int j=idx;j>i;j--)
             {
                 ch=str[j];
                 str[j]=str[j-1];
                 str[j-1]=ch;
             }
         }
      }
      cout<<str<<endl;
      return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

//using namespace __gnu_pbds;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void there_are_fates_worse_than_death() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

const long double PI = acos(-1.0);
int rowstep[] = {0, 0, 1, -1}, colstep[] = {1, -1, 0, 0};
const int N = 15e4+1;
int arr[N];

int main() {
    there_are_fates_worse_than_death();
    string str;
    cin >> str;
    int k;
    cin >> k;
    for(int i=0; i<(int)str.size()-1; ++i){
        int idx = i,sw=i;
        char mx = str[i];
        for(int j=i; j<(int)str.size(); ++j){
            if(max(i,j-k) == idx && str[j] > mx){
                mx = str[j];
                idx = max(i,j-k);
                sw = j;
            }
        }
        for(int j = sw; j>i; --j){
            swap(str[j],str[j-1]);
            k--;
        }
    }
    cout << str;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ll long long
#define vi vector<int>
#define ii pair<int,int>
#define vii vector< ii >

using namespace std;

int main(){
    string s;cin>>s;
    int k;cin>>k;
    ll size = sz(s);
    ll i = 0;
    while(k && i < size){
        ll end = min((ll)k+i+1,size);
        ll maxIdx = max_element(s.begin()+i,s.begin()+end)-s.begin();
        while(k&&maxIdx>i){
            swap(s[maxIdx],s[maxIdx-1]);
            maxIdx--;
            k--;
        }
        i++;
    }
    cout << s;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    ll i, len, k, old, pos, j, cnt, cr=0, mx=0;

    cin>>s>>k;
    len=s.size();
    for(i=0; i<len; i++)
    {
        if(k<=0)break;
        old=s[i]-48;
        mx=old;
        cnt=0;
      for(j=i+1; j<len; j++)
      {
        if(cnt==k)break;
        pos=s[j]-48;
        if(pos>mx)
        {
            mx=pos;
            cr=j;
        }
        cnt++;
      }
      //cout<<mx<<" "<<old<<endl;
      if(mx>old)
      {
        ll t=cr;
        while(i!=t)
        {
            swap(s[t],s[t-1]);
            t--;
        }
        k-=(cr-i);
      }
    }
    cout<<s<<endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void getarr(long long num, vector <int>& v)
{
    while(num>=1)
    {
        v.push_back(num%10);
        num/=10;
    }
}
long long returnnum(vector <int>& v)
{
    long long num = 0;
    //reverse(v.begin(), v.end());
    for(int i=0;i<v.size();i++)
    {
        num = num*10+v[i];
    }
    return num;
}
void shift(vector<int> &v, int to, int from)
{
    for(int i=from; i> to; i--)
    {
        //cout<<"vi "<<v[i]<<"vi-1 "<<v[i-1]<<endl;
        swap(v[i], v[i-1]);
        //cout<<"vi "<<v[i]<<"vi-1 "<<v[i-1]<<endl;
    }
}
int main()
{
    vector<int> narray;
    long long num;
    int k, idx;
    cin>>num>>k;
    getarr(num, narray);
    reverse(narray.begin(), narray.end());
    if(!k)
    {
        cout<<num<<endl;
        return 0;
    }
    for(int i = 0; i < narray.size()-1; i++)
    {
        if(i+k <= narray.size()-1)
        {
            //cout<<"inside "<<i<<" "<<i+k<<" "<<narray.size()<<endl;
            if(narray[i] < *max_element(narray.begin() + i + 1, narray.begin() + i + k + 1))
            {
                //cout<<i<<" "<<narray[i]<<" "<<k<<" "<<
                //*max_element(narray.begin() + i + 1, narray.begin() + i + k + 1)<<endl;
                idx = max_element(narray.begin() + i + 1, narray.begin() + i + k + 1) - narray.begin();
                //cout<<"idx"<<idx<<" i"<<i<<endl;
                shift(narray, i, idx);
                k -= (idx-i );
                //cout<<returnnum(narray)<<endl;
            }
        }
        else
        {
            if(narray[i] < *max_element(narray.begin() + i + 1, narray.end()))
            {
                //cout<<"ff"<<returnnum(narray)<<endl;
				//cout<<"i: "<<i<<" v[i] "<<narray[i]<<" k: "<<k<<" max_e: "<<
                //max_element(narray.begin() + i + 1, narray.end()) - narray.begin()<<endl;
                idx = max_element(narray.begin() + i + 1, narray.end()) - narray.begin();
                shift(narray, i, idx);
                k -=  (idx-i);
                //cout<<"fg"<<returnnum(narray)<<endl;
            }
        }
        if(!k) break;
    }
    cout<<returnnum(narray)<<endl;
    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <cstring>
#include<set>
#include<algorithm>
#include<vector>
#include<sstream>
#include<queue>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v)	((v).begin()), ((v).end())
#define sz(v)	((int)((v).size()))
const int OO = (int)1e6;
const double EPS = (1e-7);
typedef long long ll;
typedef vector<int> vi;
//vector<int> vis;
int dx[] = { 1, 1, -1, -1, 2, 2, -2, -2 };
int dy[] = { 2, -2, 2, -2, 1, -1, 1, -1 };
bool valid(int r, int c){
	return (r >= 0 && r < 5 && c >= 0 && c < 4);
}
int main(){
	vector<vi>v(10); int k, i = 0;
	string s; cin >> s >> k;
	while (s[i] != '\0'){ int x = s[i] - '0'; v[x].push_back(i); i++; }i = 0;
	while (s[i] != '\0'&&k>0){
		int x = s[i] - '0'; if (x == 9){
			i++; continue;
		}
		int j = 9, b = 0;
		while (j>x){
			stringstream is; is << j; string o = is.str();
			if (sz(v[j])>0){
				while (sz(v[j])>0){
					int z = (v[j][0] - i);
					if (z <= 0)	v[j].erase(v[j].begin());
					else if (z <= k){
					s.insert(i, o);
					s.erase(s.begin() + v[j][0]+1);
					k -= ((v[j][0] - i)); v[j].erase(v[j].begin()); b = 1; break;
					}
					else if (z>k)break;

				}
			}if (b)break;
			j--;
		}
		i++;int ff=i;
		v=vector<vi>(10);
	while (s[ff] != '\0'){ int x = s[ff] - '0'; v[x].push_back(ff); ff++; }

	}
	cout << s;
}

//#include "pch.h"
#include <iostream>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>

#define MIN(a,b) ((a) < (b) ? (a) : (b))

using namespace std;

int main()
{
	string s;
	int k;
	int ptr = 0, max;
	char c = s[0];
	cin >> s >> k;
	int n = s.length();
	int min = MIN(n, k);

	while (k) {
		min= MIN(n, k);
		max = 0;
		c = s[ptr];
		for (int i = ptr; (i <= ptr + min) && i < n; i++) {
			if (c < s[i]) {
				max = i;
				c = s[i];
			}
		}
		if (max) {
			for (int y = max; y > ptr; y--) {
				s[y] = s[y - 1];
				k--;
			}
			s[ptr++] = c;
		}
		else {
			ptr++;

		}
		if (ptr == n)
			break;
	}
	cout << s << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int k,pos;
	char maxx = '0';
	scanf("%d",&k);
	for(int i = 0; i < s.length(); i++)
	{
		pos = i;
		for(int j = i + 1; j <= i + k && j < s.length(); j++)
		{
			if(s[j] > s[pos]) pos = j;
		}
		if(pos == i) continue;
		for(int j = pos; j > i; j--)
		{
			swap(s[j],s[j - 1]);
		}
		k -= pos - i;
		if(!k) break;
	}
	cout<<s;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin>>s;
    int i=0,j=1,k,l=1,r=0,p;cin>>k;
    while(k&&j<s.size())
    {  p=s[i];
        while(j<=i+k&&j<s.size())
        {
            if(s[j]>p)r=j,p=s[j];j++;
        }
       if(p!=s[i]){ for(l=r;l>i;l--)swap(s[l],s[l-1]);
        k-=(r-i);}
        i++,j=i;
    }
    cout<<s;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<memory.h>
#include<vector>
#include<stdio.h>
#include<map>
#include<queue>
#include<sstream>
#include<cmath>
#include<math.h>
#define s(x) sort(x.begin(),x.end())
#define r(x) reverse(x.begin(),x.end())
using namespace std;
typedef long long ll;
int main(){
	string s;
	int k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '9')continue;
	char mx = -1; int imx = -1;
		for (int j = i+1; j < s.size()&&k; j++)
		{
			if (s[j]>s[i]){
				if (mx < s[j])
				{
					if (k >= j - i)
						mx = s[j], imx = j;
				}
			}
		}
		if (mx != -1)
		{
			for (int t = imx; t>i; t--)
				swap(s[t], s[t - 1]),k--;
		}

	}
	cout << s << endl;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string num;
    int k;
    cin>>num >>k;

    for(int i = 0 ; i<num.size() && k ;++i)
    {
        int mx = num[i] - 48 ,pos=-1;
        for(int j = i+1  ; j <=min(i + k,(int)num.size()-1);++j)
        {
            int c = num[j] - '0';
            if(c > mx ){mx = c,pos = j;}
        }
        if(pos!=-1)
        {
            num.erase(num.begin() + pos);
            char c= mx+48;
            num.insert(num.begin() + i,c);
            k-=(pos - i);
        }
    }
    cout << num <<endl;
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long int
using namespace std;
#define clr(v , d)	memset(v , d , sizeof v)
#define sz(v)		((int)(v).size())
const int VISITED = 1;
const int UNVISITED = -1;
const long long OO = 1e12;
const int OOI = 1e9;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
int xdir[] = { 1, -1, 0, 0 };
int ydir[] = { 0, 0, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
	//freopen("interesting.in", "r", stdin);
#endif
}

int main() {
	file();
	string str;
	int k;
	cin >> str >> k;

	int mx_pos = -1;
	for (int i = 0; i < sz(str) && k; i++) {
		int mx = -1;
		for (int j = i; j < sz(str) && k - (j - i) >= 0; j++)
			if (mx_pos == -1 || (str[j] > mx )) {
				mx_pos = j;
				mx = str[j];
				if (k - (j - i) <= 0)
					break;
			}

		int ind = mx_pos;
		while (k > 0 && ind >= 1 && str[ind] > str[ind - 1]) {
			swap(str[ind], str[ind - 1]);
			ind--;
			k--;
		}
	}

	cout << str << endl;
	return 0;
}

#include <bits/stdc++.h>

#define lp(x,n) for(int i = x ; i < n ; i++)
#define ll long long
using namespace std;

int main()
{
   string s ; cin >> s ;
   int k ; cin >> k ;

   for(int i = 0 ; i < s.size() ; i++)
   {
       int j = i+1 ;
       int pos = -1 ;
       char mx = s[i] ;
       for(; j <= k+i && j < s.size(); j++)
       {
           if(s[j] > mx)
           {
               mx = s[j] ; pos = j ;
           }
       }
       if(pos != -1)
       {
           s.insert(i , string(1,mx)) ; k -= (pos - i) ;
           s.erase(pos+1 , 1) ;
       }
   }
   cout << s << endl;
}

#include <bits/stdc++.h>

#define NN 111

#define inf 0x3f3f3f3f

#define MOD 1000000007

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

char a[NN], b[NN];

int L;

int big(int u, int l){

	int i, j, k;

	for(i=9; i>=0; i--){

		for(k=u; k<=u+l&&k<L; k++)

			if(a[k]==i+'0') break;

		if(k>u+l||k>=L) continue;

		for(j=k; j>u; j--)

			a[j]=a[j-1];

		a[u]=i+'0';

		return l-(k-u);

		break;

	}

}

int main(){

	int i, k, u, l;

	cin>>a>>k;

	L=strlen(a);

	for(i=0; i<L; i++){

		l=big(i, k);

		k=l;

	}

	puts(a);

}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;

int b[24];

int main()
{
	long long a;
	int k;
	scanf("%I64d %d", &a, &k);

	int l = 0;
	while (a)
	{
		b[l++] = a % 10;
		a /= 10;
	}

	int p = l-1;
	while (k && p)
	{
		int m = b[p];
		int mi = p;
		for (int i = p-1; i >= max(0,p-k); i--)
		{
			if (b[i] > m)
			{
				m = b[i];
				mi = i;
			}
		}

		if (mi < p)
		{
			for (int i = mi; i < p; i++)
			{
				b[i] = b[i+1];
			}
			b[p] = m;
			k -= p - mi;
		}
		p--;
	}

	for (int i = 0; i < l; i++)
	{
		printf("%d", b[l-i-1]);
	}

	return 0;
}

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    char c[101];
    cin>>c>>k;
    int len=strlen(c);
    int max=0;
    int i;
    if(len==1){
        cout<<c;
    }else{

        while(k){
        for(i=0;i<len;i++){
            max=c[i];
            //cout<<c[0];
            int index=i;
            int limit =len-1;
            if(i+k<=len-1){
                limit=i+k;
            }
            for(int j=i+1;j<=limit;j++){
                if(max<c[j]){
                    max=c[j];
                    index=j;

                }
            }

            if(max!=c[i]){
                for(int j=index;j>i;j--){
                    int t=c[j];
                    c[j]=c[j-1];
                    c[j-1]=t;
                }
                k-=(index-i);
            }
            if(k==0){
                break;
            }
            if(i==len-1){
              k=0;
              break;
            }

        }
        if(i==len-1){
              k=0;
            break;
        }

    }
    for(int i=0;i<len;i++){
        cout<<c[i];
    }

    }

    return 0;
}

/*
   ~~~ BISMILLAH HIR RAHMANIR RAHIM ~~~
   Problem Name:
       Platform:
     Algorithom:
  Author's Name: RC Tushar

                 শুনেছি তোমার ভীষণ রাগ ?
                              সে কি রাগ , নাকি
                                     মগজ কোণে পচন ধরা
                 পুরনো কোডের বাগ ?

 ~~~     Never Lost Hope     ~~~
*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define PS system("pause")
#define siter(n,T1)  for(set<T1>::iterator it=n.begin();it!=n.end();it++)
#define miter(n,T1,T2)  for(map<T1,T2>::iterator it=n.begin();it!=n.end();it++)
#define meter(n,T1,T2)  for(map<T1,T2>::iterator it=n.end();it!=n.begin();it--)
#define FOR(s,e,inc) for(int i=s;i<=e;i+=inc)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define Sfor(n) for(int i=1;i<=n;i++)
#define inf (1<<30)
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define sz(x) ((int)x.size())
#define eps 1e-9
#define gcd(x,y) __gcd(x,y)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define on(x,w)  x=x|(1<<w)
#define check(x,w) (x&(1<<w))==(1<<w)?true:false
#define all(x) (x).begin(),(x).end()
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf printf
#define ll long long int
#define ull unsigned long long int
#define MOD 1000000007
#define sqr(x) (( (x)* (x))%MOD)
#define cube(x)   ( (sqr(x)*(x))%MOD)
#define bit_cnt(x)   __builtin_popcount(x)
#define INT(c)  ((int)((c) - '0'))
#define CHAR(i) ((char)(i + int('0')))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define btz(a)   __builtin_ctz(a)
#define Mems(p,n) memset(p, n, sizeof(p))
#define makeint(n,s)  istringstream(s)>>n
#define BOUNDARY(i,j,Row,Col) ((i >= 0 && i < Row) && (j >= 0 && j < Col))
#define ubound(d,val)  int (upper_bound (d.begin(), d.end(), val) - d.begin())
#define lbound(d,val)  int (lower_bound (d.begin(), d.end(), val) - d.begin())
#define M 100000
using namespace std;

//int dx[]= {1,0,-1,0};
//int dy[]= {0,1,0,-1};                        //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};     //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};   //Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1};              //Hexagonal Direction
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,bool> pib;
typedef pair<double,double> pdd;
typedef pair<int,char> pic;
typedef pair< int, pii> ipii;

//TEMPLATES
template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

int st(int n,int pos)
{
    return n=n | (1<<pos);
}
int reset(int N,int pos)
{
    return N= N & ~(1<<pos);
}
bool ck(int n,int pos)
{
    return (bool)(n&(1<<pos));
}

ll binPow(ll a, ll q, ll mud)
{
    a %= mud;
    if (q == 0) return 1;
    return ((q % 2 == 1 ? a : 1) * binPow(a * a, q / 2, mud)) % mud;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~ Code Starting Point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int k,pos;
    string a;
    cin >> a >> k;

    int ln=a.size();
    for(int i=0;i<ln;i++)
    {
        char ch='0';
        pos=i;
        for(int j=i;j<=min(i+k,ln-1);j++)
        if(ch<a[j])
        {
            ch=a[j];
            pos=j;
        }
        for(int j=pos-1;j>=i;j--)
            swap(a[j],a[j+1]);

        k-=pos-i;
    }
    cout<<a<<endl;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define fp(i,k) for(i=0;i<k;i++)
#define fm(i,k) for(i=k;i>=0;i--)
#define fr(i,j,k) for(i=j;i<k;i++)
#define pb push_back
#define vll vector<ll>
#define vst vector<string>
#define vch vector<char>
#define pii pair<ll,ll>
#define vpr vector<pii>
#define psi pair<string,ll>
#define pis pair<ll,string>
#define pci pair<char,ll>
#define pic pair<ll,char>
#define msi map<string,ll>
#define mci map<char,ll>
#define mis map<ll,string>
#define mic map<ll,char>
#define mss map<string,string>
#define mii map<ll,ll>
#define mp make_pair
#define ld double
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define stp(x) cout<<setprecision(x)<<fixed
#define aa first
#define bb second
#define be begin()
#define en end()
#define si size()
#define le length()
#define imin LONG_LONG_MIN
#define imax LONG_LONG_MAX
#define INF 0x3f3f3f3f
#define all(v) v.begin(),v.end()
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ost;
ll mod=1000000007;

ll binaryexpo(ll a,ll b){
    ll res = 0; // Initialize result
    a = a % mod;
    while (b > 0){
        // If b is odd, add 'a' to result
        if (b % 2 == 1)
            res = (res + a) % mod;

        // Multiply 'a' with 2
        a = (a * 2) % mod;

        // Divide b by 2
        b /= 2;
    }

    // Return result
    return res % mod;
}
ll mulmod(ll x,ll n){
	ll result=1;
	while(n>0){
		if(n%2==1) result=binaryexpo(result,x);
		//cout<<result<<"\n";
		x=binaryexpo(x,x);
		n/=2;
	}
	return result;
}
ll getSum(ll n) {
    ll sum = 0;
    while (n != 0)
    {
     sum = sum + n % 10;
     n = n/10;
    }
 return sum;
 }

void printpri(vll &arr){

		vector<bool>prime(10000001,true);
		int k=0;
	for(int i=2;i*i<=10000000;i++){
		if(prime[i]==true){

			for(int j=i*i;j<=10000000;j+=i){
				prime[j]=false;
			}
		}
	}
	for(int i=2;i<=10000000;i++)
		if(prime[i]){
			//cout<<i<<"\n";
			arr[k++]=i;
		}
}
int  main(){
	ll r,d,i,t,j,n,m,q,f,l,a,b,x,s,c,k,y;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	string ss;
	cin>>ss>>k;
	s=0;
	f=0;
	fp(i,ss.length()){
		x=ss[i]-'0';
		c=i;
		for(j=i+1;j<=(i+k) && j<ss.length();j++){
			if((ss[j]-'0')>x){
				x=ss[j]-'0';
				c=j;
			}
		}
		f=c-i;
		if(x!=(ss[i]-'0')){
			for(l=c;l>i;l--){
				ss[l]=ss[l-1];
			}
			ss[i]=char(x+'0');
			if(k-f>0)
				k-=f;
			else break;
		}
	}
	cout<<ss;

	cout<<"\n";

	return 0;
}

#include <bits/stdc++.h>

using namespace std;
long long a;
int k,x[20],n=1;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>k;
    while(a>0){
        x[n]=a%10;
        a/=10;
        n++;
    }
    reverse(x+1,x+n);
    for(int i=1;i<n;i++){
        int vt=i,gtmax=x[i],gh=k+i;
        if(gh>n)gh=n;
        for(int j=i;j<=gh;j++)if(x[j]>gtmax){vt=j;gtmax=x[j];}
        if(gtmax!=0){
        if(k>=vt-i){
            for(int j=vt;j>i;j--)x[j]=x[j-1];
            x[i]=gtmax;
            k-=vt-i;
        }else{
            for(int j=vt;j>vt-k;j--)x[j]=x[j-1];
            x[vt-k]=gtmax;
            break;
        }
        }
    }
    for(int i=1;i<n;i++)cout<<x[i];
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

void gn(INT &x){

	char c;

	while(c=getchar(),c<'0'||c>'9');

	for(x=0;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());

}

char s[30];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int k,mx,ed;

	scanf("%s %d",s,&k);

	int n=strlen(s);

	for(int i=0;i<n;i++){

		mx=0;

		ed=0;

		for(int j=i+1;j<n;j++){

			if(s[j]-s[i]>mx&&j-i<=k){

				mx=s[j]-s[i];

				ed=j;

			}

		}

		if(!ed) continue;

		if(k==0) break;

		k-=ed-i;

		for(int j=ed;j>i;j--) swap(s[j],s[j-1]);

	}

	printf("%s",s);

	return 0;

}

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <math.h>
#include <hash_set>
#include <algorithm>
#include <time.h>
#include <map>
#include <set>
#include <conio.h>
#include <stack>

#define _USE_MATH_DEFINES
#define TASK "e3"

using namespace std;

int main(){
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	long long n;
	cin >> n;
	int k;
	cin >> k;
	vector<int>vec;
	while(n){
		vec.push_back(n%10);
		n/=10;
	}
	reverse(vec.begin(),vec.end());
	int currpos=0;
	int best, bestpos;
	while(k>0 && currpos<vec.size()){
		best=-1;
		for(int i=currpos+1; i<vec.size(); i++){
			if(vec[i]>best && vec[i]>vec[currpos] && i-currpos <=k){
				best = vec[i];
				bestpos=i;
			}
		}
		if(best!=-1){
			k-=(bestpos-currpos);
			for(int j=bestpos-1; j>=currpos; --j){
				swap(vec[j],vec[j+1]);
			}
		}
		currpos++;
	}

	for(int i=0; i<vec.size(); ++i){
		printf("%d", vec[i]);
	}

	return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    char ch='0';
    int k , p , x , c ;
    string s ;
    cin >> s >> k ;
    int l=s.length();
    if(k > l*(l-1)/2)
    {   k = l * (l - 1)/2   ;}
    while(k)
    {
        c = k ;
        for(int i=0 ; i<l ; i++)
        {
            ch='0';
            if(k > l)
                c = l ;
            for(int j=i+1 ; j<i+c+1 ; j++)
            {
                if(s[j] > ch && j<l)
                {
                    ch = s[j] ;
                    p  = j    ;
                }
            }
            if(ch>s[i])
            {
                for(int x=p ; x>i ; x--)
                    swap(s[x] , s[x-1]) ;
                k = k - (p - i)   ;
                c = k ;
            }
            if(k<=0 || i==l-1 )
            { k=0 ; break ;}
        }
    }
    cout << s << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
	long long int n,temp;
	unsigned int k;
	//cin >> n >> k;
	//temp = n;
	std::vector<int> v;
	//while(temp > 0){
	//	v.push_back(temp % 10);
	//	temp /= 10;
	//}
	char tempc;
	scanf("%c",&tempc);
	while(tempc != ' '){
        v.push_back(tempc - 48);
        //cout << tempc;
        scanf("%c",&tempc);
	}
	cin >> k;
	//for (unsigned int i = 0; i < v.size(); ++i)
    //   cout << v[i] << endl;
	//for (unsigned int i = 0; i < (v.size()/2); ++i)
	//{
	//	int temporary = v[i];
	//	v[i] = v[v.size() - i - 1];
	//	v[v.size() - i - 1] = temporary;
	//}
	n = 0;
	for (unsigned int j = 0; j < v.size(); ++j){
        n = n * 10 + v[j];
	}
	//for (unsigned int i = 0; i < v.size(); ++i)
    //    cout << v[i] << endl;
	long long int maxim = n;
	for (unsigned int i = 0; i < k; ++i)
	{
		for (unsigned int j = 0; j < v.size() - 1; ++j)
		{
			if(v[j] < v[j + 1]){
				int temporary = v[j];
				v[j] = v[j + 1];
				v[j + 1] = temporary;
				break;
			}
		}
		temp = 0;
		for (unsigned int j = 0; j < v.size(); ++j)
		{
			temp = temp * 10 + v[j];
		}
		//cout << temp << " " << i << endl;
		//if(maxim < temp){
			maxim = temp;
		//}
	}
	cout << maxim << endl;
	return 0;
}

#include<bits/stdc++.h>
#define HURRY_UP ios_base::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr);
#define eb emplace_back
using namespace std;

long long n , m;

int main()
{
    HURRY_UP;
    string a , b;
    cin >> a >> n;
    b = a; m = n;
    for(int i = 0 ; i < a.length() && n ; ++i){
        for(int j = i + 1 ; j < a.length() && n ; ++j){
            if(a[i] < a[j]){
                if(j - i > n){
                    int y = j - n;
                    while(y != j){
                        swap(a[j-1],a[j]);j--;
                    }
                    n = 0;
                    break;
                }
                else{
                    int y = j;
                    while(i != y){
                        swap(a[y-1],a[y]);y --;
                    }
                    n -= j - i;
                }
            }
        }
    }
    reverse(b.begin() , b.end());
    for(int i = 0 ; i < b.length()-1 && m ; ++i){
        for(int j =  1 ; j < b.length() && m ; ++j){
            if(b[j-1] > b[j]){
                        swap(b[j-1],b[j]) , m --;
            }
        }
    }
    reverse (b.begin() , b.end());
    cout << max(a , b) << endl;
    return 0;
}

#include <iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
    // your code goes here
    ll a;
    ll k;
    int arr[20];
    cin>>a>>k;
    int index=0;
    while(a)
    {
        arr[index++]=a%10;
        a/=10;
    }

    for(int i=0;i<index/2;i++)
    {
        swap(arr[i],arr[index-1-i]);
    }

    while(k--)
    {
      for(int i=0;i<index-1;i++)
        {
          if(arr[i]<arr[i+1])
          {
            swap(arr[i],arr[i+1]);
            break;
          }
        }
    }
    for(int i=0;i<index;i++) cout<<arr[i];

    return 0;
}

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=1e5+5, OO = 0x3f3f3f3f;

int k,x,in,mx;
string s;
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("out.txt","w",stdout);
#endif
    cin>>s>>k;
    for(int i=0; i<s.size()-1; i++)
    {
        mx=0,x=0,in=0;
        for (int j=i+1; j<i+k+1; j++)
        {
            x=(s[j]-'0')-(s[i]-'0');
            if (s[i]<s[j]&&x>mx )
            {
                mx=x;
                in=j;
            }
        }
        if(k==0)
        {
            cout<<s<<endl;
            return 0;
        }
        if(in)
        {
            for(int a=in;a>i;a--){
            swap(s[a],s[a-1]);
            k--;
            }
        }

    }

    cout<<s<<endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
#include <cstring>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

void solve()
{
	string s; cin >> s;
	int k; cin >> k;

	int n = s.size();
	string ss = s;
	sort(ss.begin(), ss.end());

	int si = 0;
	for(si = 0; si < n; ++si)
	{
		if(s[si] != ss[si]) break;
	}

	while(k)
	{
		int mx = 0, mxi = si;
		for(int i = si; i <= si + k && i < n; ++i)
		{
			if(s[i] - '0' > mx)
			{
				mx = s[i] - '0';
				mxi = i;
			}
		}
		if(si >= n || mxi >= n)
			break;

		swap(s[si], s[mxi]);
		k -= mxi - si;
		++si;
	}
	cout << s << '\n';
}

int main ()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "rt", stdin);
   freopen("output.txt", "wt", stdout);
#endif

   	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc = 1;
//	cin >> tc;
	while(tc--) solve();
}

/*
    __  __
   |  \/  |
   | \  / | ___  ___  ___  ___
   | |\/| |/ _ \/ __|/ _ \/ __|
   | |  | | (_) \__ \  __/\__ \
   |_|  |_|\___/|___/\___||___/

*/

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/* GEOMETRY START

const double PI  = acos(-1.0);
const double EPS = 1e-10;
typedef complex<double> point;

#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
//#define polar(r,ang)            ((r)*exp(point(0,ang)))  ==> Already added in c++11
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))

int dcmp(double a,double b)
{
	return fabs(a-b) < EPS ? 0 : a < b ? -1 : 1;
}

point reflect(point p, point p0, point p1) {
    point z = p-p0, w = p1-p0;
    return conj(z/w)*w + p0; // Refelect point p around p0p1
}

double fixAngle(double A) {
	return A > 1 ? 1 : (A < -1 ? -1 : A);
}

// return min angle: aOb / bOa
// dp(v1, v2) = |v1|*|v2|*cos(theta)
double angleO(point a, point O, point b) {
  point v1(a - O), v2(b - O);
  return acos( fixAngle ( dp(v1, v2) / length(v1) / length(v2) ) );
}

double getAng(point &a, point &b, point &c) // find angle abc, anticlock bc to ba
{
    double ang = angle( vec(b, c)) - angle( vec(b, a));
    if(dcmp(ang, 0) < 0)
    	ang+=2*PI;
    return ang;
}

bool isCollinear(point a, point b, point c) {
	return fabs( cp(b-a, c-a) ) < EPS;
}

bool isPointOnRay(point p0, point p1, point p2) {
    if(length(p2-p0) < EPS) return true;
    return same( normalize(p1-p0), normalize(p2-p0) );
}

bool isPointOnSegment(point a, point b, point c) {
	return isPointOnRay(a, b, c) && isPointOnRay(b, a, c);
}

double distToLine( point p0, point p1, point p2 ) {
	return fabs(cp(p1-p0, p2-p0)/length(p0-p1)); // area = 0.5*b*h
}

//distance from point p2 to segment p0-p1
double distToSegment( point p0, point p1, point p2 ) {
	double d1, d2;
	point v1 = p1-p0, v2 = p2-p0;
	if( (d1 = dp(v1, v2) ) <= 0)	return length(p2-p0);
	if( (d2 = dp(v1, v1) ) <= d1)	return length(p2-p1);
	double t = d1/d2;
	return length(p2 - (p0 + v1*t) );
}

 GEOMETRY END */

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+9;
const int N = 1e5+7;

int main()
{
	vector<pair<int,int> > vec;
	string ss;
	int k;
	cin >> ss >> k;
	int n = ss.size();
	rep(i,n)
	{
		vec.pb({ss[i]-'0',-i});
	}

	sort(vec.rbegin(),vec.rend());
	int last = 0;
	rep(i,n)
	{
		if (-vec[i].s <= k) {k+= vec[i].s;cout << vec[i].f;ss.erase(-vec[i].s,1);}
		else break;
		repA(j,i+1,n-1) if (-vec[j].s > i) vec[j].s++;
		last++;
	}
	//n = ss.size();
	repA(i,last,n-1)
	{
		char c = ss[0];
		int tmp = 0;
		repA(j,1,(int)ss.size()-1)
		{
			if (ss[j] > c && j <= k) {c = ss[j];tmp = j;}
		}
		k -= tmp;
		cout << c;
		ss.erase(tmp,1);
	}
	cout << '\n';

    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    for (int i = 0, j = 0; i < k; i++){
        for (j = 0; (j < n - 1) && (s[j] >= s[j + 1]); j++);
        if (j == n) break;
        swap(s[j], s[j + 1]);
    }
    for (int i = 0; i < n; i++){
        cout << s[i] - '0';
    }
    //cin >> n;
}

#include <bits/stdc++.h>
using namespace std;

signed main(){
  ios::sync_with_stdio( 0 );
  string a; int k; cin >> a >> k;
  for( int i = 0; i < k; ++i ){
    for( int j = 0; j + 1 < a.size(); ++j ){
      if( a[ j ] < a[ j + 1 ] ){
        swap( a[ j ], a[ j + 1 ] );
        break;
      }
    }
  }
  cout << a << endl;
  return 0;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

#define MAX 100

int k;
char a[MAX];

int main ()
{
	//freopen ("input1.txt", "r", stdin);
	scanf ("%s", &a);
	scanf ("%d", &k);
	long maxpos, i, j, h, oldj;
	j = 0;
	while (k > 0)
	{
		maxpos = j + 1;
		for (i = j + 2; i <= k + j; i++)
			if (a[i] > a[maxpos]) maxpos = i;
		//if ((a[maxpos] > a[j]) && ((maxpos - j) <= k))
		if (a[maxpos] > a[j])
		{
			for (i = maxpos; i >= j + 1; i--) swap(a[i], a[i-1]);
			k -= maxpos - j;
			j++;
		}
		else if (a[maxpos] == a[j])
		{
			oldj = j;
			while (a[j] == a[maxpos]) j++;
			if ((j - oldj) >= k)
			{
				j = oldj + 1;
				continue;
			}
			i = j + 1;
			while (a[j] >= a[i]) i++;
			if ((i - j) > k)
			{
				continue;
			}
			for (h = i; h >= j + 1; h--) swap(a[h], a[h-1]);
			k -= i - j;
			j++;
		}
		else
		{
			for (i = k + j + 1; i < strlen(a); i++)
				if (a[i] > a[j])
				{
					for (h = i; h >= i - k + 1; h--) swap(a[h], a[h-1]);
					k = 0;
					j++;
					break;
				}
			j++;
		}
	}
	printf ("%s", a);
	return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	string a;cin>>a>>n;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		for (int i = 0; i < a.length()-1; ++i)
		{
			/* code */
			if(a[i+1]>a[i])
			{
				swap(a[i+1],a[i]);
				break;
			}
		}
	}
	cout<<a;
	return 0;
}

//============================================================================
// Name        : ACM.cpp
// Author      : Moment
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define N 100

char num[N],num1[N];
int k;

void DFS(int s,char str[])
{
	if(s)
	{
		for(int i = 1;str[i];i++)
		{
			swap(str[i],str[i - 1]);
			char tmp[N];
			strcpy(tmp,str);
			DFS(s - 1,tmp);
			swap(str[i - 1],str[i]);
		}
	}
	else if(strcmp(num1,str) < 1)
		strcpy(num1,str);
}

int main()
{
	char str[N];
	while(cin >> num >> k)
	{
		if(k >= strlen(num))
		{
			sort(num,num + strlen(num));
			for(int i = strlen(num) - 1;i >= 0;i--)
				cout << num[i];
			cout << endl;
			continue;
		}
		strcpy(str,num);
		strcpy(num1,num);
		DFS(k,str);
		puts(num1);
	}
}

#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

/*ll NcR(ll n, ll r)
{
    ll p = 1, k = 1;
    if (n - r < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;
            ll m = __gcd(p, k);
            p /= m;
            k /= m;

            n--;
            r--;
        }
    }
    else
        p = 1;

    return p;
} */

int main()
{
    _fastio
    string s;
    ll k;
    cin>>s>>k;

    for(ll i=0;i<s.size();i++)
    {
        ll mx,idx;
        for(ll j=i+1;j<s.size();j++)
        {
            if(j==i+1)
            {
                mx=s[j];
                idx=j;
            }
            else
            {
                if(s[j]>mx)
                {
                    mx=s[j];
                    idx=j;
                }
            }
        }
        if(mx>s[i])
        {
            ll nd=idx-i;
            if(nd<=k)
            {
                ll t=idx;
                while(t!=i)
                {
                    swap(s[t],s[t-1]);
                    t-=1;
                }
                k-=nd;
            }
        }
    }
    cout<<s<<en;
}

#include <stdio.h>
#include <ctype.h>
//#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

#define MAX 100

int k;
char a[MAX], c;

int main ()
{
	//freopen ("input1.txt", "r", stdin);
	scanf ("%s", a);
	scanf ("%d", &k);
	long maxpos, i, j, h, oldj;
	j = 0;
	while (k > 0)
	{
		maxpos = j + 1;
		for (i = j + 2; i <= k + j; i++)
			if (a[i] > a[maxpos]) maxpos = i;
		if (a[maxpos] > a[j])
		{
			for (i = maxpos; i >= j + 1; i--) swap(a[i], a[i-1]);
			k -= maxpos - j;
			j++;
		}
		else j++;
	}
	for (i = 0; i < strlen(a); i++)
	{
		if (isdigit(a[i])) printf ("%c", a[i]);
	}
	//if (a[0] == 'd') printf ("5");
	//else printf ("%s\n", a);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct{
char num;
int pos;
}H;

char a[1000];
H c[1000];

int swap(char* a,char* b)
{
   *a = *a + *b;
   *b = *a - *b;
   *a = *a - *b;
   return 0;
}
int swap2(H *a,H *b)
{H temp=*a;
    *a=*b;
    *b=temp;
return 0;
}
int fswap(int x,int x1,int x2)
{ int i;
    for(i=x2;i>=x1&&a[i]>a[i-1];i--)
    {
       if(x2-i>=x){/*printf("break\n");*/break;}
     //  printf("== %d\n",x2-i-1);
        swap(&a[i],&a[i-1]);
    }
return x2-i;
}

int cmpfunc (const void * a, const void * b)
{
   return ( *(char*)a - *(char*)b );
}

int main()
{
int x,i;
scanf("%s%d",a,&x);
for(i=0;i<strlen(a);i++)
{
 c[i].num=a[i];
 c[i].pos=i;
}

qsort(c,strlen(a),sizeof(H),cmpfunc);
for(i=0;i<strlen(a)/2;i++)
swap2(&c[i],&c[strlen(a)-1-i]);
/*
for(i=0;i<strlen(a);i++)
{
 printf("%d- %c ",i+1,c[i].num);
 printf("%d\n",c[i].pos);
}
*/
for(i=0;i<strlen(a);i++)
{//printf("%d %c %d %c \n",c[strlen(a)-1-i].pos,c[strlen(a)-1-i].num,strlen(a)-1-i,a[c[strlen(a)-1-i].pos]);
 if(abs(c[i].pos-i)<=x&&abs(c[i].pos-i)!=0)
    {
        //printf("%c %d %d x=%d %d %s\n",a[i],i,c[i].pos,x,abs(c[i].pos-i),a);
        int y=fswap(x,i,c[i].pos);
        x=x-y;
        //printf("%c %d %d x=%d %d %s\n",a[i],i,c[i].pos,x,abs(c[i].pos-i),a);
              //       if(i==0||c[i].pos==0)x=x-abs(c[i].pos-i)+1;
                //          else x=x-abs(c[i].pos-i);
// printf("y=%d x=%d %s\n",y,x,a);
    }
//if(c[strlen(a)-1-i].num>a[c[strlen(a)-1-i].pos]&&(c[strlen(a)-1-i].pos)-(strlen(a)-1-i)<=x)
//{
 // fswap(i,strlen(a)-1-i);
//}
}
printf("%s\n",a);
    return 0;
}

#include <iostream>

using namespace std;

string s;

int k;

int main()
{
	cin >> s >> k;
	int i = 0;
	while (k != 0){
		int inulysan, sonunnomeri;
		inulysan=s[i]-48;
		if (i+k <= s.length()){
			for (int j = i+1; j <= i+k; j++){
				if (s[j]-48 > inulysan){
					inulysan=s[j]-48;sonunnomeri=j;
				}
			}
		}

		for (int g = sonunnomeri; g > i; g--)
			swap(s[g],s[g-1]);

		k -= sonunnomeri-i;
		s[i]-48;
		i++;
	}

	cout << s;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

	string s;
	int n;
	cin >> s;
	cin >> n;
	for (int i = 0; n && i<s.size(); i++)
	{

		int x = i - 1;
		int j = i;
		while (x >= 0 && n && s[j] > s[x])
		{
			char ch = s[x];
			s[x] = s[j];
			s[j] = ch;

			x--;
			n--;
			j--;
		}
	}
	cout << s << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string num; cin >>num;
    int l = num.size();

    int k; cin >>k;

    int mi;
    char t, mx;

    for(int i=0; i<l and k; i++) {
        mx = num[i];
        mi = i;
        for(int j=i+1; j<=i+k; j++) {
            if(mx<num[j]){
                mx = num[j];
                mi = j;
            }
        }
        for(int j=mi; i+1<=j; j--) {
            t = num[j-1];
            num[j-1] = num[j];
            num[j] = t;
            k--;
        }
    }
    cout <<num;

    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char Max(string arr,int n,int m){
    int ma = '0';
    for(int i = 0 ; i <= n && i < m ; i++){
        if(arr[i] > ma) ma = arr[i];
    }
    return ma;
}
int main()
{
    string s; int m;
    cin>>s>>m;
    string s2 ;
    s2 = s;
    int n = s.size();
    sort(&s2[0],&s2[0]+m,greater<int>());
    int i = 0;
    while(s2[i]==s[i] && i < n){
        i++;
    }
    while(i<n && m > 0){
        int k = i;
        int l;
        int Max = s[i];
        for(int k = i ; k <= i+m && k < n ; k++){
            if(s[k]>Max) {
                Max = s[k];
                l = k;
            }
        }
        m -= (l-i);
        swap(s[i],s[l]);
        i++;
    }
    cout<<s;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

string num;

int main()
{
        ios_base :: sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> num >> k;
	int n = num.size();
	for (int i = 0 ; i < n ; ++i)
	{
		char mx = num[i];
		for (int j = i + 1; j < n ; ++j)
		{
			if (mx < num[j] && (j - i) <= k)
			{
				k -= (j - i);
				num = num.substr(0, i) + num[j] + num.substr(i, j - i) + num.substr(j + 1);
				break;
			}
		}
		if (!k) break;
	}
	cout << num << '\n';
}

#include<bits/stdc++.h>
#include<string.h>
using namespace std;

long long n;
int k;

void swapIt(int i, int m , vector <int> &Array)
{
    int temp=0;
    temp = Array[m];
    for(int j=m;j>i;j--)
    {
        Array[j]=Array[j-1];
    }
    Array[i]=temp;
}

 int main()
{
    cin>>n>>k;
     std::vector<int> digitArray;
    while (n > 0)
    {
        int digit = n%10;
        n /= 10;
        digitArray.push_back(digit);
    }
    std::reverse(digitArray.begin(), digitArray.end());
    for(unsigned int i=0;i<digitArray.size() && k>0;i++){
        int m=i;
        int index=0;
        int max=digitArray[i] + 1;
        int flag=0;
        //if((m+k)>digitArray.size())
        //break;
        int c= digitArray.size();
        for(m=min(m+k,c);m>i;m--){
        if(digitArray[m]>=max){
        max=digitArray[m];
        flag =1;
        index=m;
        }
        if(max>digitArray[i] && flag == 1)
        {
            swapIt(i,index,digitArray);
            k = k - (m-i);
        }

        }
    }
for(unsigned int i=0;i<digitArray.size();i++)
cout << digitArray[i];

}

#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define ll long long int
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
inline void INP()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
  #endif
}

int findMax(string &s, int i, int j) {

  int ans = 0;
  int idx = -1;

  repA(k,i,j) {
    int num = s[k]-'0';
    if (num!=0 && num>=ans) {
      idx = k;
      ans = num;
    }
  }

  return idx;

}

int findPos (string &s, int i, int j, int num) {

  repA(k,i,j) {

    int n = s[k]-'0';

    if(num>n) {
      return k;
    }

  }

  return -1;

}

void rotate (string &s, int i, int j) {

  int temp = s[j];

    repD(k,j,i+1) {

      s[k]=s[k-1];

  }

  s[i] = temp;

}

void solve(){

  string s;
  cin>>s;

  int k;
  cin>>k;

  int n = s.length();

  int i=0;

  while (k>0 && i<s.length()) {

    int max_pos = findMax(s,i,min(n-1,i+k));

    //db(max_pos);

    if(max_pos==-1) {
      i++;
      continue;
    }

    int original_max_pos = findPos(s,i,min(n-1,i+k),s[max_pos]-'0');
   // db1(original_max_pos);

    if (original_max_pos==-1) {
      i++;
      continue;
    }

    rotate(s,original_max_pos,max_pos);

    k-=(max_pos-original_max_pos);

    //db1(s);

    i = original_max_pos+1;

  }

  db1(s);

}

int main(){
 int t=1;
 //cin>>t;
while(t--){
 solve();
  }
  return 0;
}

#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
using namespace std;

int find_max(int first, int end, string a){
    int i, max = first;
    for(i=first + 1; i<=end; i++){
        if(a[i] > a[max])
            max = i;
    }
    return max;
}

int main(){
    int k, i = 0, j, max, size;
    char sup;
    string a;
    cin>>a>>k;
    size = a.size();
    while(k > 0){
        max = find_max(i, i+k, a);
        k = k - max + i;
        for(j=max;j>i;j--){
            sup = a[j];
            a[j] = a[j-1];
            a[j - 1] = sup;
        }
        i++;

    }
    cout<<a;
}

#include <iostream>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
#define  ll long long int
#define UI unsigned ll int
const int N = 1e5+9, M = 1e7, OO = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
#define endl '\n'
#define pairs pair<int,int>
#define loop(i,n) for(int i = 0;i < int(n);++i)
#define rloop(i,n) for(int i = int(n-1);i>=0;--i)
#define range(i,a,b) for(int i = int(a);i <=int(b);i++)
#define P(a) printf("%d ",a)
#define S(n) scanf("%d",&n)
#define S2(n,m) scanf("%d %d",&n,&m)
#define S3(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define TestCases int t;S(t);
int size;
void convert(ll num, ll arr[])
{
    while (num)
    {
        arr[size++]=num%10;
        num/=10;
    }
    reverse(arr,arr+size);
}
int main() {//TestCases
    ll n,k,arr[N];
    cin>>n>>k;
    convert(n,arr);
    loop(i,size)
    {
        int j=i+1,idx=i,temp=idx;
        while (j-i<=k&&j<size)
        {
            if(arr[j]>arr[i]){
                idx=j;
                temp=idx;
                while (temp>i)
                {
                    swap(arr[temp],arr[temp-1]);
                    temp--;
                    k--;
                }
            }
            j++;
        }
    }
    loop(i,size)cout<<arr[i];
return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define DEBUG(debug_x) cerr <<#debug_x<<": "<<debug_x<<endl;
#define DEBUG2(debug_x, debug_y) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<endl;
#define DEBUG3(debug_x, debug_y, debug_z) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<" "<<#debug_z<<":"<<debug_z<<endl;
#define DEBUGVC(debug_x) cerr <<#debug_x<<": "; for(auto a:debug_x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(debug_x) cerr <<#debug_x<<":"<<endl; for(auto a:debug_x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (2000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;

int func(string a){
	int res=0;
	int n = a.length();
	int k = 1;
	for(int i=n-1; i>=0; i--){
		res += (a[i]-'0')*k;
		k*=10;
	}
	//DEBUG(res);
	return res;
}

signed main() {
	string a;
	int k;
	cin >> a >> k;
	int n = a.length();

	int ans=func(a);
	string b=a;
	while(1){
		//DEBUG2(ans, k);
		for(int i=0; i<n; i++){
			int m = k;
			a = b;
			for(int j=i; j>0; j--){
				if(m==0) break;
				swap(a[j],a[j-1]);
				//DEBUG(a);
				m--;
				int val = func(a);
				if(ans < func(a)){
					ans = func(a);
					k = m;
					b = a;
				}

			}
		}
		if(k==0) break;
	}

	cout << ans << endl;

}

#include <bits/stdc++.h>

using namespace std;
long long a;
int k,x[19],n=1;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>k;
    while(a>0){
        x[n]=a%10;
        a/=10;
        n++;
    }
    reverse(x+1,x+n);
    for(int i=1;i<n;i++){
        int vt=i,gtmax=x[i],gh=k+i;
        for(int j=i;j<=gh;j++){
            if(gh>n)gh=n;
            if(x[j]>gtmax){vt=j;gtmax=x[j];}
        }
        if(gtmax!=0){
        if(k>=vt-i){
            for(int j=vt;j>i;j--)x[j]=x[j-1];
            x[i]=gtmax;
            k-=vt-i;
        }else{
            for(int j=vt;j>vt-k;j--)x[j]=x[j-1];
            x[vt-k]=gtmax;
            k=0;
        }
        }
        if(k==0)break;
    }
    for(int i=1;i<n;i++)cout<<x[i];
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
    main()
    {
        int  a , k;
        cin >> a >> k;
        string s;
        bool check = false;
        while(a)
        {
            s += (char)(48+(a % 10));
            a /= 10;

        }
        reverse(s.begin(),s.end());

        int t = 0;
        while(k > 0)
        {
        check = true;
        int maxe = 0;
        int pos = 0;
        for(int i = t+1 ; i < s.size() and i <= k ;i++)
        {
            if(maxe < s[i]-48)
            {
                maxe = s[i] - 48;
                pos  = i;

            }

        }
        if(maxe == 0 and pos == 0)
        {
            check = false;
            int tt = 0;
            int pos1 = 0;
            for(int i = t + 1 ; i < s.size();i++)
            {
                if((s[i] - 48 ) != 0){tt = (s[i] - 48);pos1 = i;break;}

            }
            if(pos1 == 0)break;
            for(int i = pos1 -1 ; i >= 0; i--)
            {
                if(s[i] < s[i + 1] and k){swap(s[i],s[i+1]);k--;}

            }

        }
        // 45008 5
        for(int i = pos - 1; i >= 0;i--)
        {

            if( s[i] < s[i+1] and k ){swap(s[i+1],s[i]); k--;}
            else break;

        }
        check ? t++ : t;

        }
        cout << s;

    }

#define encoding_505                  \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);                \
    cerr.tie(nullptr);
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
bool comp(pair<int,int> a, pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    return a.first>b.first;
}
int main()
{
    encoding_505;
    string a;
    int k, i, j;
    cin >> a >> k;

    vector<pair<char,int>> vp;

    for(i=0; i<a.size(); i++) {
        vp.push_back(make_pair(a[i], i));
    }

    int index;
    sort(vp.begin(), vp.end(), comp);

    // for(i=0; i<vp.size(); i++) cout<<vp[i].first<<" "<<vp[i].second<<"\n";
    // cout<<"\n";

    for(i=0; k>0 && i<a.size(); i++) {
        index=i;
        for(j=0; j<vp.size(); j++) {
            if(vp[j].first>a[i] && vp[j].second-i >= 0 && vp[j].second-i <= k) {
                    index = vp[j].second;
                    for(int u=index-1; u>=0; u--) {
                        vp[a[u]-'0'].second++;
                    }
                    swap(vp[j], vp[vp.size()-1]);
                    vp.pop_back();
                    sort(vp.begin(), vp.end(), comp);
                    break;
            }
        }
        // cout<<a[i]<<" "<<a[index]<<"\n";
        if(index!=i) {
            k-=(index-i);
            for(j=index; j>i; j--) {
                swap(a[j], a[j-1]);

            }
        }
        // cout<<a<<"\n";
    }
    cout<<a;
    return 0;
}

/*
    Look at me!
    Look at me!
    Look at how large the monster inside me has become!
*/

#include<fstream>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#define FIT(a,b) for(vector<int >::iterator a=b.begin();a!=b.end();a++)
#define FITP(a,b) for(vector<pair<int,int> >::iterator a=b.begin();a!=b.end();a++)
#define RIT(a,b) for(vector<int>::reverse_iterator a=b.end();a!=b.begin();++a)
#include<stack>
#define ROF(a,b,c) for(int a=b;a>=c;--a)
#include<vector>
#include<algorithm>
#define FOR(a,b,c) for(int a=b;a<=c;++a)
#define REP(a,b) for(register int a=0;a<b;++a)
#include<cstring>
#include<bitset>
#include<cmath>
#include<iomanip>
#include<ctime>
#define f cin
#define g cout
#include<queue>
#define debug cerr<<"OK";
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define mod 666013
#define inf 1<<30
#define N 200100
#define DIM 10000000
using namespace std;
/*int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};*/

char s[N];
int n,k,p,ma,cost;

int main ()
{

    #ifndef ONLINE_JUDGE
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    #endif

    f>>(s+1)>>k;
    n=strlen(s+1);
    p=1;
    while(k)
    {
        ma=p;
        cost=0;
        int hey=0;
        FOR(i,p,n)
        if(s[i]>s[ma]&&i-p<=k)
        {
            cost=i-p;
            ma=i;
        }
        else
        if(s[i]>s[ma])
        hey=1;
        if(ma==p&&hey)
        {
            FOR(i,p,n)
            if(s[i]>s[ma])
            {
                ma=i;
                break;
            }
            while(k)
            {
                swap(s[ma],s[ma-1]);
                --ma;
                --k;
            }
            break;
        }
        if(!ma)
        break;
        ROF(i,ma,p+1)
        swap(s[i],s[i-1]);
        k-=cost;
        ++p;
        if(p>=n)
        break;
    }
    g<<(s+1);
    return 0;
}

/*IN THE NAME OF GOD*/
/*year:2015 month:1 day: codeforces level:Pupil*/
#include <iostream>
#include <conio.h>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int x[3][3];

int main()
{
	string a;
	int b; cin >> a >> b;
	int length = a.length();
	for (int i = 0; i < b; i++)
	{
		for (int i = 0; i < length-1; i++)
		{
			if (a[i] < a[i + 1]){
				swap(a[i], a[i + 1]);
				break;
			}
		}
	}
	cout << a;
	//_getch();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

void c_p_c()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   #ifndef ONLINE_JUDGE
	freopen("/home/abhinav/c++ codes/input output c++/input.txt", "r", stdin);
	freopen("/home/abhinav/c++ codes/input output c++/output.txt", "w", stdout);
   #endif

   string s;
   int k;
   cin >> s >> k;

   int swaps_left = k;
   int tmp = 0;
   int idx = -1;
   char max = '\0';

   for (int i = 0; i < s.length(); i++) {
   		max = s[i];
   		for (int j = i + 1; j < s.length(); j++) {

   			swaps_left--;

   			if (s[j] > max) {
   				max = s[j];
   				//cout << "max = " << max << endl;
   				idx = j;
   				tmp = swaps_left;
   			}

   			if (swaps_left == 0) {
   				for (int l = idx; l >= i + 1; l--) {
   					swap(s[l], s[l - 1]);
   				}

   				swaps_left = tmp;
   				tmp = 0;
   				break;
   			}
   		}
   }

   cout << s << endl;
}

int32_t main()
{
    c_p_c();
    return 0;
}

#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
#define ms0(a) memset(a,0,sizeof(a))
#define ms1(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
using namespace std;
//typedef __int64 ll;
const int M = 2e9;
const int N = 1e5+5;
char a[20];
int main()
{
    int k;
   cin>>a>>k;
   int l=strlen(a);
   int x=0;
   int st=0;
   while(1)
   {
       char c='0';
       int j;
       for(int i=st;i<l&&i<=k;i++)
       {
            if(a[i]>c)
            {
                c=a[i];
                j=i;
            }
       }
        if(c=='0'||st==l-1)
            break;
        char s=a[j];
        for(int i=j;i>st;i--)
            a[i]=a[i-1];
        a[st]=s;
        k-=j-st;
        st++;
   }
   cout<<a<<endl;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,k;
ll a;
struct node
{
	int bb,p;
}b[20];
int c[20];
int main()
{
	scanf("%I64d %d",&a,&k);
	int d=1;
	while(a>0)
	{
		b[d].bb=a%10;
		c[d]=b[d].bb;
		b[d].p=d++;
		a/=10;
	}
	int pos=d-1;
	while(k>0)
	{
		bool flag=false; int tmp=c[pos],tp=pos;
		for(int i=pos-1;i>=1;i--)
		{
			if(b[i].bb>tmp&&pos-i<=k)
			{
				tmp=b[i].bb;
				 tp=i;
				 flag=true;
			}
		}
		if(!flag)
		{
			pos--;
			if(pos<=1)break;
		}
		else
		{
			for(int j=d-1;j>=1;j--)
				{
					if(b[j].p<=pos&&b[j].p>tp)
					{
						b[j].p--;
					}
					else if(b[j].p==tp)
					{
						b[j].p=pos;
					}
				}
				 k-=(pos-tp);
				 for(int j=1;j<d;j++)
				 {
				 	c[b[j].p]=b[j].bb;
				 }
				 pos--;
				 if(pos<=1)break;
		}
	}
	for(int i=d-1;i>=1;i--)
	{
		printf("%d",c[i]);
	}
	puts("");
}

#include<iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;

int main() {
    string str;
    cin>>str;
    int t;
    cin>>t;
    if(t==0||str.size()==1) {
        cout<<str<<endl; return 0;
    }
    int ind=-1;
    for(int i=0;i<str.length();i++){
        ind=-1;
        char cur=str[i];
        if(t<=0) break;
        for(int j=i+1;j<=i+t;j++) {
           if(str[j]>cur) {
             cur=str[j];
             ind=j;
           }
        }
        if(ind!=-1) {
            for(int k=ind;k>i;k--) {
                swap(str[k],str[k-1]);
            }
            t-=(ind-i);
        }
    }
    cout<<str<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstring>
#include <iterator>
#include <fstream>
using namespace std;

#define pb push_back
#define rs resize
#define mp make_pair
#define inf 1e9
#define pi 3.1415926535897932384626433832795
#define sz(a) (int)(a).size()
#define Sort(a) sort((a).begin(), (a).end())
#define Reverse(a) reverse((a).begin(), (a).end())
#define sf scanf
#define pf printf
#define ms(a, x) memset((a), (x), sizeof(a))
#pragma(comment, linker("\STACK:50000000"))
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <vvi> vvvi;
typedef vector <vvvi> vvvvi;
typedef vector <bool> vb;
typedef vector <vb> vvb;
typedef vector <vvb> vvvb;
typedef vector <vvvb> vvvvb;
typedef long long ll;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef vector <vvl> vvvl;
typedef vector <vvvl> vvvvl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> vvii;
typedef pair <int, ll> il;
typedef vector <il> vil;
typedef vector <vil> vvil;
typedef pair <ll, int> li;
typedef vector <li> vli;
typedef vector <vli> vvli;
typedef set <int> si;
typedef set <li> sli;
typedef set <il> sil;
typedef vector <string> vs;
typedef vector <vs> vvs;
typedef vector <vvs> vvvs;
typedef map <string, int> msi;
typedef map <char, int> mci;
typedef pair <ll, ll> pll;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a;
    cin >> a;
    int k;
    cin >> k;
    for (int i = 1; i < sz(a) && k > 0;) {
        if (a[i] > a[i - 1]) {
            swap(a[i], a[i - 1]);
            --i;
            --k;
        }
        else{
            ++i;
        }
    }
    cout << a;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{   string a;
int k;
char x;
cin>>a>>k;
for(int i=0;i<k;i++)
{for(int j=0;j<a.length()-1;j++)
{if(a[j+1]>a[j])
{x=a[j];
a[j]=a[j+1];
a[j+1]=x;
break;
}
//break;

}

}
cout<<a<<endl;
return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
	int m,n,i,j,a,ans,num;
	char s[50];
	while(scanf("%s%d",s,&n)!=-1)
	{
		while(n--)
		{
			for(i=0;s[i];i++)
			{
				if(s[i]<s[i+1])
				{
					char c=s[i];
					s[i]=s[i+1];
					s[i+1]=c;
					break;
				}
			}
		}
		printf("%s\n",s);
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define el      	'\n'
#define ft 			first
#define sd 			second
#define mp(x,y)  	make_pair((x),(y))
#define pb(x)    	push_back((x))
#define all(v)  	((v).begin()),((v).end())
#define rall(v)		v.rbegin(),v.rend()
#define sz(x)  		((int) (x).size())
#define lp(i,n) 	for(int i=0;i<(int)n;i++)
#define lpv(i,a,n) 	for(int i=a;i<=(int)n;i++)
#define clr(a,b)	memset(a,b,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;

const double PI = 2 * acos(0.0), EPS = 1e-9;
const int INF = 1e9, NINF = -1e9, MOD = 1e9 + 7;
int dx[8] = { -1, -1, 0, 1, 1, 1, 0, -1 },
		dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
void GO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(20);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

int main() {
	GO();
	string s ; int k  ; cin >> s  >> k  ;
	lp(i,sz(s)){
		int  mx = -1 ,mxi = 0, kk = k ;
		for (int j = i +1 ; j< sz(s) && kk ; j++ , kk--){
			if (mx < s[j]-'0'){
				mxi = j ;
			}
		}
		while (s[mxi] -'0' > s[mxi-1] -'0' && mxi && k ){
			swap(s[mxi] , s[mxi -1] )  ;
			--mxi;
			--k ;
		}
	}
	cout << s ;
	return 0;
}

#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long int lli;
int main()
{

lli n,k;
cin>>n>>k;
lli temp = n;
int i=0;
int a[20];
int b[20];

while(temp>0)
{
	int d = temp%10;
	temp = temp/10;
	a[i++]=d;
}
int no_dig=i;
reverse(a,a+i);
for(i=0;i<no_dig;i++) cout<<a[i];
i=0;
int j=0;
int ma;
int m;
int l;

while(true)
{
if(i==no_dig || k==0) break;
	ma = i;
	m=a[i];
	for(l=i+1;l<no_dig;l++){
		if(a[l]>m) { m = a[l]; ma = l; break;}
		}
	//cout<<ma<<endl;
	while(a[ma]>a[i] && k>0)
	{
		int t=a[ma];
		a[ma] = a[ma-1];
		a[ma-1] = t;
		ma--;
		k--;
	}
	i++;
}

for(i=0;i<no_dig;i++) cout<<a[i];

return 0;
}

#include <iostream>
using namespace std;
#include<vector>
string s1;
vector<int>s;
void convert (long long int i,long long int j)
{
    char temp;
    while(j>i)
    {
        swap(s[j],s[j-1]);
        j-=1;
    }
}
int main()
{
    int k;
    cin>>s1>>k;
    long long int l = s1.length(),i,j;
    if(k==0)
    {
        cout<<s1<<endl;
        return 0;
    }
    for(i=0;i<l;i++)
    {
        s.push_back(s1[i]-48);
    }

    for(i=0;i<l;i++)
    {
        bool flag = false;
        if(s[i] == 9)
            continue;
        long long int temp = k,pos=0,max = s[i],swap = 0;
        for(j=1;j<=temp and j<l;j++)
        {
            if(max<s[i+j])
            {
                pos =j;

                max= s[j+i];
                swap = j;

            }
        }
        if(swap != 0)
        convert(i,i+swap);

        k=k-swap;
        if(k==0)
            break;
    }
    for(i=0;i<l;i++)
        cout<<s[i];
    cout<<endl;
    return 0;
}
                //

#include <bits/stdc++.h>
using namespace std;

string s;
int n;

int main() {
    cin >> s >> n;

    while(n--) {
        string curMax = s;
        for(int i = 0; i + 1 < s.size(); ++i) {
            string tmp = s;
            swap(tmp[i], tmp[i + 1]);
            curMax = max(curMax, tmp);
        }
        s = curMax;

    }
    cout << s << endl;
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(){
    char c[20],tmp;
    int k,i,d,s;
    cin>>c>>k;
    s=0;
    while(s<strlen(c)){
        tmp = '0';
        for(i=s;i<strlen(c);i++){
            if(tmp<c[i]&&(i-s)<=k) {tmp=c[i];d=i;}
        }
        for(i=d;i>s;i--){
            tmp = c[i];
            c[i] = c[i-1];
            c[i-1] = tmp;
        }
        k-=(d-s);
        if(!k) break;
        //cout<<s<<" "<<d<<"\n";
        s++;
    }
    cout<<c<<"\n";
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> A;
int k;

int main()
{
	long long d;
	cin >> d;
	while (d)
	{
		A.push_back(d % 10);
		d /= 10;
	}
	reverse(A.begin(), A.end());
	cin >> k;

	int lim = 0;
	while (k--)
	{
		int mx = 1;
		for (size_t i = 1; i < A.size(); ++i)
			if (A[i] > A[mx]) mx = i;
		for (int i = mx; i > lim; --i)
			swap(A[i], A[i - 1]);
		++lim;
	}

	for (auto a : A)
		printf("%d", a);

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; i < n; i++)
#define r(i, k, n) for (int i = k; i >= n; i--)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
// #define deb(x) cout << #x << "=" << x << endl
// #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
// #define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
// =================

const int mod = 1e9;
const int N = 3e5 + 1;

void solve()
{
    int n, k;
    string s;
    cin >> s >> k;
    n = len(s);
    int mx=-1;
    while (k)
    {
        bool ok=1;
        int index=0;
        char mx_ele=s[mx+1];
        f(i,mx+1,mx+k+1) {
            // deb(i);
            if(i==n-1) {
                if(!index) ok=0;
                break;
            }
            if(s[i+1]>mx_ele) index=i+1,mx_ele=s[i+1];
        }
        if(!ok) break;
        int i=mx+k+1;
        while (index==0 && i<n-1)
        {
            if(s[i+1]>s[i]) index=i+1,ok=1;
            i++;
        }
        if(!ok) break;

        // deb(index);
        while (index-1>=0 && s[index-1]<s[index] && k>0)
        {
            char tmp=s[index];
            s[index]=s[index-1];
            s[index-1]=tmp;
            index--;
            k--;
        }
        // deb(index);
        // deb(k);
        mx=index;
        // deb2(s,mx);
    }
    cout<<s;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    while (t--)
        solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int con (char c)
{
    return c - '0' ;
}
int main()
{

string s ; cin >>s ; int k ; cin >>k;
string cpy = s;
sort( cpy.begin() ,cpy.end() ) ;
int n = s.length() ;
//reverse( cpy.begin() ,cpy.end() ) ;
bool f = 1 ;
while (f && k)
{
    f=0 ;
    for (int i = 0 ; i <n-1 ; i ++)
    {
        int maxx = s[i]-'0' ;
        int from =  0 ;
       for (int x = i+1; x <n ; x ++)
    {

        if ( s[x]-'0' > maxx && abs( x-i)<=k ){ maxx = s[x]-'0' ; from = x ; f=1 ; }

    }
    cout <<from<<endl ;
        for (int e = from ; e >i; e --)
        {
            swap( s[e] , s[e-1]) ;
            k--;
        }

 }

}

cout <<s;

}

//#include<bits/stdc++.h>
//#include <fstream>
#include<iostream>
#include<cmath>
#include<time.h>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#define P_ M_PI
#define maxn 10000009
#define INF 1000000007
#define LLINF 1000000000000000007
#define mp(x,y) make_pair(x,y)
#define ff first
#define cs(x,y) cout<<"Case "<<y<<": "<<x<<endl;
#define ss second
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define ppb() pop_back()
#define tr(i, c) for(typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define rand srand( (unsigned)time( NULL ) ); int randomNumber = rand()%1001 + 1;
using namespace std;
/*
ifstream cin("file.in");
ofstream cout("file.out");
*/
vector <int> l;
long long a,b,m,n,k;
int main()
{
   cin>>a>>b;
   while(a>0)
   {
     l.pb(a%10);
     a/=10;
   }
   reverse(l.begin (),l.end ());
   while (b>0 && m<l.size()-1)
   {
   	  n=l[m];
   	  k=0;
      for(int i=m+1;i<l.size ();i++)
      {
	    if(i-m<=b && n<l[i])n=l[i],k=i;
	  }

	   if(l[m]!=n)
       {
       	 b-=(k-m);
	     for(int i=k;i>m;i--)
	         l[i]=l[i-1];
	       l[m]=n;
	   }
	   m++;
	}
     if(b>0 && b%2==0 && l.size() >1)
       swap(l[l.size ()-1],l[l.size()-2]);
     for(int i=0;i<l.size ();i++)
	  		cout<<l[i];

return 0;
}

# include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;

	int k;
	cin>> s >> k;

	int i;
	for( i=0; i<s.size(); i++)
	{
		if(s[i+1]>s[i])
		swap(s[i+1],s[i]);
		k--;

	}
	if(k>=1){

	if(s[i+1]==s[i]){

	swap(s[i+1],s[i]);
	--k;
}
}

	cout<<s;

	return 0;
}

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <numeric>
#include <set>
#include <stack>
#include <sstream>
#include <utility>
#include <vector>
#include <array>

#define push_back pb
#define eps 1e-9
#define number(a) (a - '0')

using namespace std;
typedef long long ll;

template <typename T>
void exchange(T& a, T& b) {
	T c = a;
	a = b;
	b = c;
}

int main(int argc, char * argv[]) {
	int i, j, k, p = 1;
	char max;
	string s;

	cin >> s;
	cin >> k;

	while(k) {
		max = s[p];
		for(i = p; i <= p+k; ++i) {
			if(s[i] > max) {
				j = i;
				max = s[i];
			}
		}

		for(i = j-1; i >= p; --i) {
			swap(s[i], s[i+1]);
			k--;
			if(!k) break;
		}

		p++;
	}

	cout << s << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    int k;
    cin >> s >> k;
    if (k > 0)
    {
        for (int i = 0; i<s.size(); i++)
        {
            int pos = 0;
            for (int j =i+1+ k; j >= 1; j--)
            {
                if (s[j]>s[j - 1])
                    pos = j;
            }
            for (int r = pos-1; r >= 0; r--)
            {
                if (s[pos] > s[r])
                {
                    swap(s[pos], s[r]);
                    pos--;
                    k --;

                    if (k == 0)
                    {
                        cout << s << endl;
                        return 0;
                    }
                }
            }
        }
    }
    else if (k==0)
    {
        cout << s << endl;
    }
    return 0;
}

/** Micro Mezz Macro Flation -- Overheated Economy ., Last Update: May. 7th 2014 **/ //{

/** Header .. **/ //{
#pragma comment(linker, "/STACK:36777216")
//#pragma GCC optimize ("O2")
#define LOCAL
//#include "testlib.h"
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

//#include <tr1/unordered_set>
//#include <tr1/unordered_map>
//#include <array>

using namespace std;

#define REP(i, n) for (int i=0;i<n;++i)
#define FOR(i, a, b) for (int i=a;i<b;++i)
#define DWN(i, b, a) for (int i=b-1;i>=a;--i)
#define REP_1(i, n) for (int i=1;i<=n;++i)
#define FOR_1(i, a, b) for (int i=a;i<=b;++i)
#define DWN_1(i, b, a) for (int i=b;i>=a;--i)
#define REP_C(i, n) for (int n____=n,i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<n;++i)
#define FOR_N(i, a, b) for (i=a;i<b;++i)
#define DWN_N(i, b, a) for (i=b-1;i>=a;--i)
#define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=n;++i)
#define FOR_1_N(i, a, b) for (i=a;i<=b;++i)
#define DWN_1_N(i, b, a) for (i=b;i>=a;--i)
#define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i)
#define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i)
#define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i)
#define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i)

#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define REP_S(i, str) for (char*i=str;*i;++i)
#define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i])
#define REP_G(i, u) REP_L(i,hd[u],suc)
#define REP_SS(x, s) for (int x=s;x;x=(x-1)&s)
#define DO(n) for ( int ____n = n; ____n-->0; )
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)
#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn)
#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define LBD(A, x) (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x) (lower_bound(ALL(A), x) - A.begin())
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int((A).size())
#define PB push_back
#define MP(A, B) make_pair(A, B)
#define PTT pair<T, T>
#define Ts *this
#define rTs return Ts
#define fi first
#define se second
#define re real()
#define im imag()

#define Rush for(int ____T=RD(); ____T--;)
#define Display(A, n, m) {                      \
  REP(i, n){		                            \
        REP(j, m-1) cout << A[i][j];     \
        cout << A[i][m-1] << endl;		        \
	}						                    \
}
#define Display_1(A, n, m) {                    \
	REP_1(i, n){		                        \
        REP_1(j, m-1) cout << A[i][j] << " ";   \
        cout << A[i][m] << endl;		        \
	}						                    \
}

typedef long long LL;
//typedef long double DB;
typedef double DB;
typedef unsigned uint;
typedef unsigned long long uLL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;

template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
//inline int RD(){int x; return RD(x);}
inline LL RD(){LL x; return RD(x);}
inline DB& RF(DB &);
inline DB RF(){DB x; return RF(x);}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){char c; return RC(c);}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();}

template<class T> inline T& RDD(T &);
inline LL RDD(){LL x; return RDD(x);}

template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
inline char& RC(char &a, char &b){RC(a), RC(b); return a;}
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}
inline void RS(char *s1, char *s2){RS(s1), RS(s2);}
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}
template<class T0,class T1>inline void RDD(T0&a, T1&b){RDD(a),RDD(b);}
template<class T0,class T1,class T2>inline void RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T> inline void CLR(T &A){A.clear();}

template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}
template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(stack<T> &S){while (!S.empty()) S.pop();}

template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}

template<class T> inline bool EPT(T &a){return a.empty();}
template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;}
template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}
template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;}
template<class T> inline T& UNQQ(T &A){A.resize(unique(ALL(A))-A.begin());return A;}
template<class T> inline T& UNQ(T &A){SRT(A);return UNQQ(A);}

//}

/** Constant List .. **/ //{

const int MOD = int(1e9) + 7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-9;
const DB OO = 1e20;
const DB PI = acos(-1.0); //M_PI;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//}

/** Add On .. **/ //{
// <<= '0. Nichi Joo ., //{

template<class T> inline T& checkMin(T &a,const T b){if (b<a) a=b;return a;}
template<class T> inline T& checkMax(T &a,const T b){if (a<b) a=b;return a;}
template<class T> inline T& checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);return a;}
template<class T> inline T& checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);return a;}
template <class T, class C> inline T& checkMin(T& a, const T b, C c){if (c(b,a)) a = b;return a;}
template <class T, class C> inline T& checkMax(T& a, const T b, C c){if (c(a,b)) a = b;return a;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);}
template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
template<class T> inline T ceil(T x, T y){return (x - 1) / y + 1;}
template<class T> T abs(T x){return x>0?x:-x;}
inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);}

inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);}
inline DB cot(DB x){return 1./tan(x);};
inline DB sec(DB x){return 1./cos(x);};
inline DB csc(DB x){return 1./sin(x);};

//}
// <<= '1. Bitwise Operation ., //{
namespace BO{

inline bool _1(int x, int i){return bool(x&1<<i);}
inline bool _1(LL x, int i){return bool(x&1LL<<i);}
inline LL _1(int i){return 1LL<<i;}
inline LL _U(int i){return _1(i) - 1;};

inline int reverse_bits(int x){
    x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
    x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
    x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
    x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
    x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);
    return x;
}

inline LL reverse_bits(LL x){
    x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);
    x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);
    x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);
    x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);
    x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);
    x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);
    return x;
}

template<class T> inline bool odd(T x){return x&1;}
template<class T> inline bool even(T x){return !odd(x);}
template<class T> inline T low_bit(T x) {return x & -x;}
template<class T> inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}
template<class T> inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}
template<class T> inline int cover_idx(T x){int p = 0; while (_1(p) < x ) ++p; return p;}

inline int clz(int x){return __builtin_clz(x);}
inline int clz(LL x){return __builtin_clzll(x);}
inline int ctz(int x){return __builtin_ctz(x);}
inline int ctz(LL x){return __builtin_ctzll(x);}
inline int lg2(int x){return !x ? -1 : 31 - clz(x);}
inline int lg2(LL x){return !x ? -1 : 63 - clz(x);}
inline int low_idx(int x){return !x ? -1 : ctz(x);}
inline int low_idx(LL x){return !x ? -1 : ctz(x);}
inline int high_idx(int x){return lg2(x);}
inline int high_idx(LL x){return lg2(x);}
inline int parity(int x){return __builtin_parity(x);}
inline int parity(LL x){return __builtin_parityll(x);}
inline int count_bits(int x){return __builtin_popcount(x);}
inline int count_bits(LL x){return __builtin_popcountll(x);}

} using namespace BO;//}

// <<= '2. Number Theory .,//{
namespace NT{
inline LL gcd(LL a, LL b){return __gcd(a, b);}
inline LL lcm(LL a, LL b){return a*b/gcd(a,b);}

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

inline int gcd(int m, int n, int &x, int &y){

    x = 1, y = 0; int xx = 0, yy = 1, q;

    while (1){
        q = m / n, m %= n;
        if (!m){x = xx, y = yy; return n;}
        DEC(x, pdt(q, xx)), DEC(y, pdt(q, yy));
        q = n / m, n %= m;
        if (!n) return m;
        DEC(xx, pdt(q, x)), DEC(yy, pdt(q, y));
    }
}

inline int sum(int a, int b, int c){return sum(a, sum(b, c));}
inline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}
inline int pdt(int a, int b, int c){return pdt(a, pdt(b, c));}
inline int pdt(int a, int b, int c, int d){return pdt(pdt(a, b), pdt(c, d));}

inline int pow(int a, LL b){
    int c(1); while (b){
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

template<class T> inline T pow(T a, LL b){
    T c(1); while (b){
        if (b&1) c *= a;
        a *= a, b >>= 1;
    }
    return c;
}

template<class T> inline T pow(T a, int b){
    return pow(a, (LL)b);
}

inline int _I(int b){
    int a = MOD, x1 = 0, x2 = 1, q;
    while (true){
        q = a / b, a %= b;
        if (!a) return (x2 + MOD) % MOD;
        DEC(x1, pdt(q, x2));

        q = b / a, b %= a;
        if (!b) return (x1 + MOD) % MOD;
        DEC(x2, pdt(q, x1));
    }
}

inline void DIV(int &a, int b){MUL(a, _I(b));}
inline int qtt(int a, int b){return pdt(a, _I(b));}

struct Int{
    int val;

    operator int() const{return val;}

    Int(int val = 0):val(val){
        val %= MOD; if (val < 0) val += MOD;
    }
    Int(LL _val){
        _val %= MOD; if (_val < 0) _val += MOD;
        val = _val;
    }
    Int& operator +=(const int& rhs){
        INC(val, rhs);
        return *this;
    }
    Int operator +(const int& rhs) const{
        return sum(val, rhs);
    }
    Int& operator -=(const int& rhs){
        DEC(val, rhs);
        return *this;
    }
    Int operator -(const int& rhs) const{
        return dff(val, rhs);
    }
    Int& operator *=(const int& rhs){
        MUL(val, rhs);
        return *this;
    }
    Int operator *(const int& rhs) const{
        return pdt(val, rhs);
    }
    Int& operator /=(const int& rhs){
        DIV(val, rhs);
        return *this;
    }
    Int operator /(const int& rhs) const{
        return qtt(val, rhs);
    }
    Int operator-()const{
        return MOD-*this;
    }
};

/*
Int Fact[N], Factt[N]; Int Binom(int n, int m){
    return Fact[n] * Factt[m] * Factt[n-m];
}
*/

/*
    Fact[0] = 1; REP_1(i, N-1) Fact[i] = Fact[i-1] * i;
    Factt[N-1] = _I(Fact[N-1]); DWN(i, N, 1) Factt[i-1] = Factt[i] * i;
*/

/*
    int Binom[N][N];
    REP(i, N){Binom[i][0] = 1; REP_1(j, i) Binom[i][j] = Binom[i-1][j-1] + Binom[i-1][j];}
*/

/*
const int PMAX = 1;
VI P; bitset<PMAX> isP;
void sieve(){
    FOR(i, 2, PMAX){
        if (!isP[i]) P.PB(i);
        for (int j=0;j<SZ(P)&&i*P[j]<PMAX;++j){
            isP[i*P[j]]=1; if (!(i%P[j])) break;
        }
    }
}
*/

/*
inline int phi(int n){
    int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){
        DEC(res, qtt(res, i));
        do{n /= i;} while(!(n%i));
    }
    if (n != 1)
        DEC(res, qtt(res, n));
    return res;
}
*/

/*LL d, x, y; void exGcd(LL a, LL b){
    if(!b) x = 1, y = 0, d = a;
    else{
        exGcd(b, a%b); LL t = y;
        y = x - (a/b)*y, x = t;
    }
}*/

} using namespace NT;//}
//}

/** I/O Accelerator Interface .. **/ //{
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x){
    char c;while(!d);x=c-'0';while(d)p;
    return x;
}
template<class T> inline T& RDD(T &x){
    char c;while(g,c!='-'&&!isdigit(c));
    if (c=='-'){x='0'-g;while(d)n;}
    else{x=c-'0';while(d)p;}
    return x;
}
inline DB& RF(DB &x){
    //scanf("%lf", &x);
    char c;while(g,c!='-'&&c!='.'&&!isdigit(c));
    if(c=='-')if(g=='.'){x=0;DB l=1;while(d)nn;x*=l;}
        else{x='0'-c;while(d)n;if(c=='.'){DB l=1;while(d)nn;x*=l;}}
    else if(c=='.'){x=0;DB l=1;while(d)pp;x*=l;}
        else{x=c-'0';while(d)p;if(c=='.'){DB l=1;while(d)pp;x*=l;}}
    return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
inline char* RS(char *s){
    //gets(s);
    scanf("%s", s);
    return s;
}

LL last_ans; int Case; template<class T> inline void OT(const T &x){
    printf("Case #%d: ", ++Case);
    //printf("%lld\n", x);
    //printf("%.6f\n", x);
    printf("%d\n", x);
    //cout << x << endl;
    //last_ans = x;
}
//}

//}/* .................................................................................................................................. */

const int N = 109;
int b[N];
int n, nn;

int main(){

#ifndef ONLINE_JUDGE
   freopen("in.txt", "r", stdin);
#endif

    LL a, k; RD(a, k);
    LL t = a;
    while (t){
        b[n++] = t % 10;
        t /= 10;
    }

    if (!k || n == 1){
        cout << a << endl;
    }
    int nn = n - 1;
    while (k > 0 && nn > 0){
        int nnn = nn;
        for (int i=nn;i>=0 && i>=nn-k;i--) if (b[i] > b[nnn]) nnn = i;

        //cout << nnn << " " << nn << endl;

        FOR(i, nnn, nn){
            swap(b[i],b [i+1]);
            if (!--k) break;
        }
        --nn;
    }
    //cout << n << endl;

    DWN(i, n, 0) cout << b[i];
    puts("");
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	string S;
	int k;
	cin>>S>>k;

	if(S.size()==1)
	{
		cout<<S;
		return 0;
	}

	int t;
	for (int i = 0; i < S.size()-1; ++i)
	{
		t=i;
		for (int j = i+1; (j<S.size())&&(j<=i+k) ; ++j)
		{
			if(S[j]>S[t])
			{
				t=j;
			}
		}
		while(t!=i)
		{
			swap(S[t],S[t-1]);
			t--;
		}
		k-=(t-i);
		if(!k)
		{
			break;
		}
	}

	cout<<S;
	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
	string a;
	int k;
	cin >> a >> k;

	for(int i=0 ; i < a.length(); i++){
		int j=i;
		while(k != 0 && j>0 && a[j]>a[j-1]){
			swap(a[j],a[j-1]);
			j = j-1;
			k--;
		}
	}
	cout << a;

}

#include <cstdio>
#include <iostream>
#include <algorithm>

//#pragma comment(linker, "/STACK:10000000")

using namespace std;

const int N = 1e5+10;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        //freopen ("output.txt","w",stdout);
    #endif

    char a[100]={0};
    int k,max_=0,max_p=0,times=0;
    cin >> a >> k;
    int sz = (strlen(a)-1);
    int l=0,r=sz;
    if(sz>k) r = k;
    //r = sz<k?k:sz;
    if(sz==0) { cout << a; return 0;}
    if(k==0) { cout << a; return 0;}
    for(;k;){
        for(int i=l;i<=r;i++){
            if(max_<a[i]) {
                max_=a[i];
                max_p=i;
            }
        }
        if(max_p==0) {
            l++;
            if(l==r) {l=0; r=k;}
            if(sz!=r) r=l+k;
            max_=0;
            continue;
        }
        for(int i=max_p;i!=l;i--){
            int temp = a[i];
            a[i] = a[i-1];
            a[i-1]=temp;
            k--;
            if(k==0) break;
        }
        l++;
        if(l==r) {l=0; r=k;}
        if(sz!=r) r=l+k;
        max_=0;
        times++;
        if(times==2000) break;
    }
    cout << a;
    return 0;
}

#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
using namespace std;
template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
int main(){
  long long a;
  cin>>a;
  int k;
  cin>>k;
  string s = toString(a);
  int n = s.size();
  for(int i = 0; i < n - k; ++i){
    int p = s[i] - '0';
    int best = i;
    for(int j = i; j <= i + k; ++j){
      if(s[j] - '0' > p){
	best = j;
      }
    }
    int t = best - i;
    int x = best;
    for(int j = 0; j < t; ++j){
      char c; c = s[x]; s[x] = s[x-1]; s[x-1] = c;
      x--;
    }
    k -= best - i;
  }
  cout<<s<<endl;
  return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <stack>
#include <map>
#include <set>
#define make_pair mp
#define swap(a,b) {char t=a;a=b;b=t;}
typedef long long ll;
using namespace std;
string s;
int n, len, p, q,MAX,ok;
int main(){

	cin >> s >> n;
	len = s.size();

	if (len > 1){
		while (n&&p < len){
			MAX = 0;
			while (p < len&&s[p] == '9') p++;
			for (int i = p + 1; i < len; i++){
				if (s[p] < s[i] && i - p <= n&&MAX < s[i]){
					MAX = s[i];
					q = i;
				}
			}
			if (MAX != 0){
				for (int j = q; j > p; j--){
					swap(s[j], s[j - 1]);
					n--;
				}
			}
			p++;
		}
		if (n){
			for (int i = 0; i < len - 1; i++)
				if (s[i] == s[i + 1]){
					ok++;
					break;
				}
			if (!ok){
				while (n--&&len > 1)
					swap(s[len - 1], s[len - 2]);

			}

		}
	}
	p = 0;
	while (s[p] == '0') p++;
	for (; p < len; p++) cout << s[p];
	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
    main()
    {
        int  a , k;
        cin >> a >> k;
        string s;
        bool check = false;
        while(a)
        {
            s += (char)(48+(a % 10));
            a /= 10;

        }
        reverse(s.begin(),s.end());

        int t = 0;
        while(k > 0)
        {
        check = true;
        int maxe = 0;
        int pos = 0;
        for(int i = t+1 ; i < s.size() and i <= k ;i++)
        {
            if(maxe < s[i]-48)
            {
                maxe = s[i] - 48;
                pos  = i;

            }

        }
        if(maxe == 0 and pos == 0)
        {
            check = false;
            int tt = 0;
            int pos1 = 0;
            for(int i = t + 1 ; i < s.size();i++)
            {
                if((s[i] - 48 ) != 0){tt = (s[i] - 48);pos1 = i;break;}

            }
            if(pos1 == 0)break;
            for(int i = pos1 -1 ; i >= 0; i--)
            {
                if(s[i] < s[i + 1] and k){swap(s[i],s[i+1]);k--;}

            }

        }
        // 45008 5
        for(int i = pos - 1; i >= 0;i--)
        {

            if( s[i] < s[i+1] and k ){swap(s[i+1],s[i]); k--;}
            else break;

        }
        check ? t++ : t;

        }
        cout << s;

    }

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

typedef long long ll;
const int MAXN = 10000;
const int INF = 100000000;
typedef double db;
typedef pair<int, int> PP;
typedef pair<ll, pair<int, int> > PL;
int n, m;

int N = 100;

int k;
string a;
int kol = 0;
int main(){
	cin >> a >> k;
	for (int i = 0; i < a.size(); i++){
		if (kol<k){
			int f = 0;
			while (i >= 0 && a[i - 1] < a[i] && kol<k){
				f = 1;
				swap(a[i], a[i - 1]), kol++;
				i--;
			}
			if (f) i = 0;
		}
	}
	cout << a;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define fp(i,k) for(i=0;i<k;i++)
#define fm(i,k) for(i=k;i>=0;i--)
#define fr(i,j,k) for(i=j;i<k;i++)
#define pb push_back
#define vll vector<ll>
#define vst vector<string>
#define vch vector<char>
#define pii pair<ll,ll>
#define vpr vector<pii>
#define psi pair<string,ll>
#define pis pair<ll,string>
#define pci pair<char,ll>
#define pic pair<ll,char>
#define msi map<string,ll>
#define mci map<char,ll>
#define mis map<ll,string>
#define mic map<ll,char>
#define mss map<string,string>
#define mii map<ll,ll>
#define mp make_pair
#define ld double
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define stp(x) cout<<setprecision(x)<<fixed
#define aa first
#define bb second
#define be begin()
#define en end()
#define si size()
#define le length()
#define imin LONG_LONG_MIN
#define imax LONG_LONG_MAX
#define INF 0x3f3f3f3f
#define all(v) v.begin(),v.end()
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ost;
ll mod=1000000007;

ll binaryexpo(ll a,ll b){
    ll res = 0; // Initialize result
    a = a % mod;
    while (b > 0){
        // If b is odd, add 'a' to result
        if (b % 2 == 1)
            res = (res + a) % mod;

        // Multiply 'a' with 2
        a = (a * 2) % mod;

        // Divide b by 2
        b /= 2;
    }

    // Return result
    return res % mod;
}
ll mulmod(ll x,ll n){
	ll result=1;
	while(n>0){
		if(n%2==1) result=binaryexpo(result,x);
		//cout<<result<<"\n";
		x=binaryexpo(x,x);
		n/=2;
	}
	return result;
}
ll getSum(ll n) {
    ll sum = 0;
    while (n != 0)
    {
     sum = sum + n % 10;
     n = n/10;
    }
 return sum;
 }

void printpri(vll &arr){

		vector<bool>prime(10000001,true);
		int k=0;
	for(int i=2;i*i<=10000000;i++){
		if(prime[i]==true){

			for(int j=i*i;j<=10000000;j+=i){
				prime[j]=false;
			}
		}
	}
	for(int i=2;i<=10000000;i++)
		if(prime[i]){
			//cout<<i<<"\n";
			arr[k++]=i;
		}
}
int  main(){
	ll r,d,i,t,j,n,m,q,f,l,a,b,x,s,c,k,y;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	string ss;
	cin>>ss>>k;
	s=0;
	f=0;
	fp(i,ss.length()){
		x=ss[i]-'0';
		c=i;
		for(j=i+1;j<=(i+k) && j<ss.length();j++){
			if((ss[j]-'0')>x){
				x=ss[j]-'0';
				c=j;
			}
		}
		f=c-i;
		if(x!=(ss[i]-'0')){
			for(l=c;l>i;l--){
				ss[l]=ss[l-1];
			}
			ss[i]=char(x+'0');
			if(k-f>0)
				continue;
			else break;
		}
	}
	cout<<ss;

	cout<<"\n";

	return 0;
}

//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
string s;
int max_num;
int k , c , findex , full_c;
int main(){
    cin>>s>>k;
    for(int i = 0 ; i < s.length() ; i++){
        max_num = int(s[i]-48);
        for(int j = i+1 ; j < s.length() ; j++){
            if(max_num<(int(s[j]-48))){
                c = j - i;
            if(full_c+c<=k && j!=s.length()) {
                max_num = int(s[j]-48);
                    findex = j;
                    if(full_c+c==k){
                        full_c+=c;
                        break;
                    }
                }
                else c = 0;
                     if(c==k) {
                           break;
                     }
            }
        }
         full_c+=c;
       for(int g = findex ; g > i  ; g--){
          swap(s[g],s[g-1]);
        }
         if(full_c>=k) break;
    }
    cout<<s<<endl;
}

#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int main()
{
    Mapogo;
    string x;
    cin >> x;
    int k;
    cin >> k;
    int c = 0;
    if (k > x.size())k = x.size() - 1;
    for i(x.size() - k) {
        int idx = -1;
        for r(r, i + 1, i + k + 1) {
            if (x[r] > x[i]) {
                idx = r;
            }
        }
        if (idx!=-1) {
            for (int r = idx; r > i; r--) {
                swap(x[r], x[r - 1]);
            }
            k -= idx - i;
        }
        if (k == 0)break;
    }
    cout << x;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    string str;
    int k;
    cin >> str >> k;
    while (k--) {
        char max_c = '0';
        int max_i = -1;
        for (int i = 0; i <= min(k+1,(int)str.size()-1) ; ++i) {
            if (max_c < str[i]) {
                max_c = str[i];
                max_i = i;
            }
        }
        if (max_i > 0) {
            char x = str[max_i];
            str[max_i] = str[max_i - 1];
            str[max_i - 1] = x;
            continue;
        }
        for (int i = 0; i < str.size() - 1; ++i) {
            if (str[i] < str[i + 1]) {
                char x = str[i];
                str[i] = str[i + 1];
                str[i + 1] = x;
                break;
            }
        }
    }
    cout << str << endl;
    return 0;
}

/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    ll a, k;
    cin >> a >> k;

    str s = "";
    while(a) {
	s += a % 10 + '0';
	a/=10;
    }
    reverse(all(s));
    ll n = s.length();
    for (int i = 0; i < n; ++i) {
	if (k <= 0) break;

	int ma = 0, in = -1;
	for (int j = i + 1; j < n; ++j) {
	    if (s[j] - '0' >= ma && j - i <= k) {
		ma = s[j] - '0';
		in = j;
	    }
	}
	debug(in, k, s);
	if (ma <= s[i] - '0') continue;
	if (in == -1) continue;
	swap(s[i], s[in]);
	k-= (in - i);
	if (k <= 0) break;
    }
    cout << s << '\n';
    return 0;
}

#include <iostream>

using namespace std;
string a;
int k;
int searching=0;
int mx=0, in=9999999;

void getmax(){
    for(int i=a.length()-1;i>=0;i--)
        if(a[i] - '0' > mx && abs(i-searching) <= k && i > searching && a[i]-'0' > a[searching]-'0')
            mx= a[i] - '0', in=i;
}

int main(){
    cin >> a >> k;

    if(a.length() == 1)
        return 0;

    while(true){

        if( k > 0 ){

            getmax();
            if(searching >= a.length())
                break;

            if(in == searching){
                cout << mx << endl;
                in=9999999, mx=0;
            }

            if(in==9999999){
                searching++;
                continue;
            }

            if(a[in] == a[in-1])
                k++;

            swap(a[in], a[in-1]);
            k--, in--;

        } else
            break;
    }

    cout << a << endl;

    return 0;
}

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

string s;
int k,a[20];

int main(){
	cin>>s;cin>>k;
	int len=s.length();
	for(int i=0;i<len;i++)a[i+1]=s[i]-'0';
	for(int i=2;i<=len;i++){
		if(a[i]>a[i-1]){
			swap(a[i],a[i-1]);
			k--;
			if(k==0)break;
			int p=i-1;
			while(a[p]>a[p-1]&&k!=0){
				swap(a[p],a[p-1]);
				k--;p--;
				if(p==1)break;
			}
			if(k==0)break;
		}
	}
	for(int i=1;i<=len;i++)cout<<a[i];
	cout<<endl;
	return 0;
}

#include <iostream>
#include <utility>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <string>
#include <string.h>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <bits/stdc++.h>
#include <ctype.h>
#include <sstream>
#define rmv(v, element)         v.erase(remove(v.begin(), v.end(), element), v.end())
#define reset(s, val)		    memset(s, val, sizeof(s))
#define rand_shuffle (arr)      random_shuffle(arr, arr+n)
#define neg_mod (a, b)          (b + (a%b)) % b
#define map_find (m, v)          m.find(v) != m.end()
#define scan_lines               scanf(" %[^\t\n]s",&str);
using namespace std;

/*
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/

struct point{
    int x, y;
};
int dist (point a, point b){
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int find_set (int a){
   /* if (a==parent[a])
        return a;
    return parent[a] = find_set (parent[a]);*/
}
bool union_set (int a, int b){
 /*   a = find_set(a), b = find_set(b);

    if (a==b) return 0;

    if (Rank[a]>= Rank[b]){
        parent[b] = a;
    }else if (Rank[b] > Rank[a] ){
        parent[a] = b;
    }
    if (Rank [a]== Rank[b]) {
        Rank[a] ++;
    }
    return 1;*/
}
struct team {
    int id, m;

    team (){}

    bool operator < (team x)const{
        return m > x.m;
    }

};
vector <int> visit(5002,0);
int cycle =0;

vector <vector <int>> graph(5002, vector <int>());
bool valid (int i, int j){
//    return (i<n && i>=0 && j<m && j>=0);
}
void dfs(long long  i, long long  p){

    visit[i]=1;
    for (long long k =0 ;k <graph[i].size() ; k++){
            if (!visit[graph[i][k]]){
                dfs (graph[i][k], i);
            }else {
                if ((graph[i][k]!=p)){
                    cycle =1;
                    return;
                }
            }

    }

}

int main()
{
    string str;
    cin >> str;
    int k;
    cin >> k;
    for (int i =0; i < str.length()-1; i++){
            if (k){
                char mx = '0';
                int temp= 0;
                for (int j =1; j <= k; j++){
                    if(str [i+j]- str[i]>0){
                        mx = max(mx, str [j]);
                        temp = i+j;
                    }
                }
                for (int j =temp; j > i; j--){
                    char t = str[j];
                    str [j] = str[j-1];
                    str[j-1] = t;
                    k--;
                }
            }
    }
    cout << str;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    string S;
    int K;
    cin >> S >> K;
    for (int i = 0; i < K; i++)
    {
        for (int j = 1; j < S.size(); j++)
            if (S[j] > S[j - 1])
            {
                swap(S[j], S[j - 1]);
                break;
            }
    }
    cout << S << endl;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <complex>
#include <cstring>
using namespace std;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()

const double EPS = 1e-6;
const int INF = 1 << 28;
const long long INFL = 1LL << 62;
const int MAX = 100001 ;
///*****************************************
/*
class XBallGame
{
public :

};
*/
string n ;
long long  k ;

///****************************************

int main()
{
	 ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);

  cin >> n >> k ;
  string x = n ;
  int  cnt = k ;

  for(int  i=k ; i>0 ;i--)
  {
      if(i>=x.size()) break ;
      if(cnt==0) break;
      if(x[i] > x[i-1])
      {
          swap(x[i] , x[i-1]);
          cnt-- ;
      }
  }

if(cnt > 0)
{
    for( int  i=1 ; i<(int )x.size() ;i++)
    {
        if(i>=x.size()) break ;
        if(cnt<=0) break ;
        for( int  j = i ; j>0 ;j--)
        {
            if(cnt<=0) break ;
            if(x[j] <= x[j-1]) break ;
            else
            {
                cnt-- ;
                swap(x[j] ,x[j-1]);
            }
        }
    }

}

cout << x << endl ;

return 0;
}

/*#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <complex>
#include <cstring>
using namespace std;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()

const double EPS = 1e-6;
const int INF = 1 << 28;
const long long INFL = 1LL << 62;
const int MAX = 100001 ;
///*****************************************
/*
class XBallGame
{
public :

};
*/
/*
long long cnt = 0;
char arr[401][401] ;
int  a ,b ;
void _check(char c1 , char c2 , char c3 , char c4)
{
    int a1 = c1-'0' , a2 =c2-'0' ,a3 =c3-'0' , a4=c4-'0' ;
    if(a1+a2+a3+a4==0) cnt+=4 ;
    else if(a1+a2+a3+a4 ==1) cnt+=2;
}

///****************************************

int main()
{
	 ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);

cin >> a >> b ;
for(int i= 0 ;i<a ;i++)
{
    cin >> arr[i] ;
}

for(int i=0 , k=i+1 ; i+1 <a ; i++ ,k++)
{
    int p = i , y=k ;
    for(int j=i+1 , m = k+1 ; j<b ; j++ , m++ , p++ , y++)
    {
        _check(arr[i][j] , arr[i][p] , arr[k][m] ,arr[k][y]);
    }
}

cout << cnt <<endl ;
return 0;
}

*/

#include<bits/stdc++.h>
#include<string>
#define ll long long
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define pi 3.1415926535897
using namespace std;
ll a[24];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(2);
    //std::cout << std::fixed;
    string s,h;
    ll k,i,j=1,x,l;
    char c='0';
    cin>>s>>k;
    h=s;
    x=k;
    ll y,f=0;
    for(i=0;i<s.size();i++)
    {
        c=s[i];
        while(j<=k && k>0 && j<s.size())
        {
            if(s[i+j]>c)
            {
                c=s[i+j];
                y=i+j;
                f=1;
                //cout<<y<<endl;
            }
            j++;
        }
        //cout<<k;
        j=1;
        if(f==1)
        {
            k-=y-i;
            s[i]=s[y];
            for(l=i+1;l<=y;l++)
                s[l]=h[l-1];
            //swap(s[i],s[y]);
            f=0;
            c='0';
            h=s;
        }
    }
    for(i=0;i<s.size();i++)
        cout<<s[i];
}

#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
char data[20],b;
long long int tmp;
int swp;
int len;
int pos;
int mp,mn;
int main(){
	scanf("%s",data);
	scanf("%i",&swp);
	pos=0;
	len=strlen(data)-1;
	if(swp==0||len==1){
		printf("%s",data);
		return 0;
	}
	int j,x1,x2,x,i;
	for(j = 0; j < len; j++){
        int x1=-1;
        for(i = j; i <= min(swp+j,len-1); i++){
            x=data[i]-'0';
            if(x>x1) x1=x,x2=i;
        }
        while(x2>j){
            b=data[x2-1];
            data[x2-1]=data[x2];
            data[x2]=b;
            swp--;
            x2--;
        }
    }
        printf("%s",data);
	return 0;
}

#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;

//            < = = = = =    GCD     = = = = = >

ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}

//            < = = = = =    LCM     = = = = = >

ll lcm(ll a,ll b)
{
    ll x=(a/gcd(a,b))*b;
    return x;
}

//            < = = = = =    power  x^n     = = = = = >

ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;

}

//            < = = = = =    CHECK FOR PRIME     = = = = = >

bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}

//            < = = = = =    SOLVE    = = = = = >

 //  void generate() {
//     memset(div, 0, sizeof div);
//     for (int i = 1; i <= N; i++) {
//         for (int j = i; j <= N; j += i) {
//             divisors[j] += 1;
//         }
//     }
// }

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }

// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }

int solve() {fastio
    string s;
    int k;
    cin>>s>>k;
    while(k--){
        f(i,1,s.length()-1,1){
            if(s[i]-'0'>s[i-1]-'0'){
                char temp = s[i];
                s[i]=s[i-1];
                s[i-1]=temp;
                break;
            }
        }
    }
    cout<<s;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >

int main() {fastio

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

#include <iostream>
using namespace std;

int main()
{
    int x,pos=0;
    string y,z;
    cin>>y>>x;
    z=y;
    while (x>0&&pos<y.size()-1)
    {
        int ind=pos;
        char maxi=y[ind];
        for (int i=pos+1;i<=pos+x;i++)
        {
            if (y[i]>=maxi)
            {
                maxi=y[i];ind=i;
            }
        }
        //swab
        if (ind !=pos)
            {
            for (int i=ind;i>pos;--i){
            char temp=y[i];
            y[i]=y[i-1];
            y[i-1]=temp;
            }
            x-=(ind-pos);

            }
        //
    pos++;
   // cout<<"Trial  "<<y<<endl;

    }

cout<<y<<endl;

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

void shift(string &s,int i,int f){
    char t = s[i];
    for(int k = i; k>f; --k)
        s[k] = s[k-1];
    s[f] = t;
}

int main(){
    string num= "";
    int s,b = 0;
    cin>>num>>s;
    int l = num.length()-1;
    while(s>0){
        if(b == l)
            break;
        int mp = b;
        for(int i = b + 1; i<=b+s; ++i)
            if(num[mp] < num[i])
                mp = i;
        shift(num,mp,b);
        s -= mp - b;
        b++;
    }
    cout<<num;
    return 0;
}

#include <iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
    // your code goes here
    ll a;
    ll k;
    int arr[20];
    cin>>a>>k;
    int index=0;
    while(a)
    {
        arr[index++]=a%10;
        a/=10;
    }

    for(int i=0;i<index/2;i++)
    {
        swap(arr[i],arr[index-1-i]);
    }
    //greedy approach to solve problem
    //from first digit starting find maximum in next k digits..
    //swap i,j and decrement k by(j-i)..

    while(1)
     {
      if(k==0) break;

      for(int i=0;i<index;i++)
      {
        int t;
        int maxi=-1;
        for(t=1;t<=k;t++)
        {
            if(arr[i+t]>maxi && arr[i+t]>arr[i]) maxi=t;
        }
        if(maxi!=-1)
        {
            //swap(arr[i],arr[i+maxi]);
            int a=arr[maxi];
            for(int j=maxi-1;j>=i;j--)
            {
               arr[j+1]=arr[j];
            }
            arr[i]=a;
            k-=(maxi);
        }
      }
     }

    for(int i=0;i<index;i++) cout<<arr[i];

    return 0;
}

/*
ID:
PROG:
LANG: C++
 */
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <climits>
#include <cstdlib>

const double Pi=acos(-1.0);
typedef long long LL;

#define Set(a, s) memset(a, s, sizeof (a))
#define Rd(r) freopen(r, "r", stdin)
#define Wt(w) freopen(w, "w", stdout)

using namespace std;

string a;
int n;

int main (int argc, char ** argv)
{
	cin >> a >> n;
	int z = 0, idx, def = 0;
	if (a.size() == 1)
		cout << a << "\n";
	else
	{
		while(n>=0 && def < a.size())
		{
			for (int i = def; i <= def+n; i++)
			{
				if (a[i]-'0' > z)
					z = a[i]-'0', idx = i;
			}
			//cout << def << " " << idx << " " << "max: " << z << " " << a << "   " << n << "\n";
			if (n == 0)
				break;
			if (idx != 0)
			{
				for (int i = idx; i >= 1 && n >= 0; i--, n--)
				{
					swap(a[i], a[i-1]);
				}
			}
			//else
			def++;
			z = 0;
			idx = -1;
		}
		cout << a << "\n";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k, i, j, l;
    string a;
    cin>>a>>k;
    l=a.size();
    for(i=0; i<l-1; i++)
    {
        if(a[i]<a[i+1]&&k>0)
        {
            for(j=i+1; j>0; j--)
            {
                if(a[j]>a[j-1]&&k>0)
                {
                    int c=a[j];
                    a[j]=a[j-1];
                    a[j-1]=c;
                    k--;
                }
                else
                {
                    break;
                }
            }

        }
        if(k==0)
        {
            break;
        }
    }
    cout<<a<<endl;
    return 0;
}

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string num;
	cin >> num;

	int k;
	cin >> k;

	int sz = num.size();
	for (int i = 0; i < sz; ++i) {
		if (num[i] == '9') {
			continue;
		}

		int best_possible_idx = -1, left_k = k;
		for (int j = i + 1; j < sz && left_k > 0; ++j) {
			if (num[j] > num[i]) {
				best_possible_idx = j;
			}

			--left_k;
		}

		if (best_possible_idx != -1) {
			for (int j = best_possible_idx; j > i; --j) {
				swap(num[j], num[j - 1]);
				--k;
			}
		}
	}

	cout << num << "\n";

	return 0;

}

/*

                 """Bismillahir Rahmanur Rahim"""

*/
#include<bits/stdc++.h>
using namespace std;
void shikariIsListening()
{
#ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);
#endif
}
#define pi 2*acos(0.0)
#define ll long long int
#define inf 922337203470075000LL
#define pb push_back
#define pf push_front
#define ek(x) __builtin_popcount(x)
#define ses '\n'
#define in(x) scanf("%lld",&x);
#define out(x) printf("%lld\n",x);
#define stm istringstream
#define all(x) x.begin(),x.end()
#define gcd __gcd
ll lcm(ll x,ll y)
{
    return (x*y)/gcd(x,y);
}
#define tin ll T;cin>>T; for(ll o=1;o<=T;o++)
#define tout cout<<"Case "<<o<<":\n";
#define spc printf(" ");
#define vll vector<ll>
#define pii pair<ll,ll>
#define fs first
#define sc second
#define sz 100015

int main()
{
    //shikariIsListening();
    string s;
    ll x;
    cin>>s;
    cin>>x;
    for(ll i=0;i<x;i++)
    {
        for(ll i=0;i<s.size()-1;i++)
        {
            if(s[i]<s[i+1])
            {
                swap(s[i],s[i+1]);
                break;
            }
        }
    }
    cout<<s<<ses;

}
/*   --------------------
    |      ~SOHAN~       |
    |   ~ShikariSohan~   |
     --------------------
    || VALAR MORGULIS||==|| ALL MEN MUST DIE ||
    \ Power Is Power//
    || I Can Do This All day ||
    // We are on a Break \ // How you doin'? \
    || Say My Name || ~~ || I Am The Who Knocks ||
    // I Am Ted Mosby Architect \
    || It Is Legen --wait for it -- dary ,Legendary ||
    \ Penny - Penny - Penny // -- Bazinga

*/

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main()
{

  long int a;
  int k;
   int swapIndex = 0;
   int otherSwapIndex =-1;
   int maxToSwap = -1;

  int valueIndex = -1;
  int max =10;
  cin>> a >> k;
  string s = to_string(a);
  while(true){
      if ( k == 0)
      {
          break;
      }

      for(int i = swapIndex ; i<s.size();i++){
          int num = s[i] - '0';
          if(num != 9 && num < max){
              swapIndex = i;
              valueIndex = num;
              break;
          }
      }
      if (valueIndex != -1){
          for(int i= swapIndex + 1 ; i<s.size();i++){
               int num = s[i] - '0';
               if(num > valueIndex && num > maxToSwap && i - swapIndex <= k ) {
                   otherSwapIndex = i;
                   maxToSwap = num;

               }
               if ( i - swapIndex == k){
                   break;
               }
          }
          if (otherSwapIndex == -1 && k!=0){
              if (swapIndex == s.size()-1)
              break;
              swapIndex++;

              continue;
          }
          else {
              for(int i=otherSwapIndex; i>swapIndex;i--)
            swap(s[i], s[i-1]);
            k = k - ( otherSwapIndex - swapIndex);
              otherSwapIndex =-1;
              maxToSwap = -1;
              valueIndex = -1;
              max =10;
          }

      }

  }

cout<<s<<endl;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

#define mp make_pair
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> PI;
typedef vector<int> VI;
typedef vector<VI> VII;

string a;
int max_index(int, int);

int main(){
    int k, i = 0;

    cin >> a >> k;

    for(int j = a.length(); k > 0;){
        int index = max_index(i + 1, j);

        while(i != j){
            if(a[index] >= a[i] && index - i <= k){
                break;
            }
            j--;
        }

        for(int y = index; y > i; y--){
            char temp = a[y - 1];
            a[y - 1] = a[y];
            a[y] = temp;
        }

        if(index != -1){
            k -= (index - i);
            i++;
        }else{
            k += index;
            i = 0;
        }
    }

    cout << a;

    return 0;
}

int max_index(int i, int j){
    int max = -1, index = -1;

    for(; i < j; i++){
        int temp = a[i] - '0';

        if(max < temp){
            max = temp;
            index = i;
        }
    }

    return index;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	string a; int turns;

	cin >> a >> turns;

	int i=0, n = a.size();

	while(turns > 0 && i<n-1){
	    int j = i+1;
	    int max_index = i;

	    while( ((j-i) <= turns) && (j<n) ) {
	        if(a[j] > a[max_index]) max_index = j;
	        j++;
	    }

	    while(max_index > i) {
	        swap( a[max_index], a[max_index-1] );
	        max_index--;
	    }

	    turns -= (j-i);
	    i++;
	}

	cout << a << endl;

	return 0;
}

/**************************************************
 * Author    : xiaohao Z
 * Blog  : http://www.cnblogs.com/shu-xiaohao/
 * Last modified : 2014-05-30 23:20
 * Filename  : Codeforce_249_2_B.cpp
 * Description   :
 * ************************************************/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned int,unsigned int> puu;
typedef pair<int, double> pid;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

const int INF = 0x3f3f3f3f;
const double eps = 1E-6;

int main()
{
//  freopen("in.txt", "r", stdin);

    char str[1010];
    int k;
    while(cin >> str){
        cin >> k;
        int len = strlen(str);
        for(int lp = 0; k && lp<len; lp++){
            int Max = -1, Mp;
            for(int i=0; i<=k; i++){
                if(i >= 0 && i < len){
                    int num = str[lp+i] - '0';
                    if(num > Max){
                        Max = num;
                        Mp = i;
                    }
                }
            }
            for(int i=Mp-1; i>=0; i--){
                if(i >= 0 && i < len-1){
                    swap(str[lp+i], str[lp+i+1]);
                    k--;
                }
            }
        }
        cout << str << endl;
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<functional>
#include<cstdio>
using namespace std;
int main() {
	string num;
	int k;
	while (cin >> num >> k) {
		int j = 0;
		for (int i = 0; i < k; i++) {
			if (num[j] < num[j + 1]) {
				swap(num[j], num[j + 1]);
				if (j > 0)j--;
			}
			else {
				--i;
				j++;
			}
		}
		cout << num << endl;
	}
	return 0;
}

#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;

const int L = 20,geps = 10;
int len,a[L+geps],k;

void Init(){
	char c;
	scanf("%c",&c);
	while(c != ' '){
		a[++len]=int(c)-int('0');
		scanf("%c",&c);
	}
	scanf("%d",&k);
}

void doing(){
	rep(j,1,len-1){
		if(a[j] < a[j+1]){
			swap(a[j],a[j+1]);
			return;
		}
	}
}

void Solve(){
	Init();
	rep(i,1,k){
		doing();
	}
	rep(i,1,len) printf("%d",a[i]);printf("\n");
}
int main(){
	Solve();
	//system("pause");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define setvec(vec,n) for(ll i=0;i<n;i++)cin>>v[i];
#define print(v,n) for(ll i=0;i<n;i++) cout<<v[i]<<" ";
#define sort(v) sort(v.begin(),v.end())
#define endl "\n"

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    string x;
    int k,a=x.size()-1;          cin>>x>>k;
    for(int i=0;i<x.size() && k!=0;i++){
        for(int j=min(k+i,a);j>i;j--){
            if(x[j]>x[j-1]){
                swap(x[j],x[j-1]);
                k--;
            }
        }
    }
    cout<<x;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
#define EPS 0.000000001
#define M_PI 3.14159265358979323846
#define CROSSPROD(a, b) (conj(a)*(b)).Y
#define DOTPROD(a, b) ((a).X*(b).X + (a).Y+(b).Y)
#define FASTIO ios::sync_with_stdio(false);

int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

template <class T>
T gcd(T a, T b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

template <class T>
T modpow(T x, T n, T m) {
    if(n == 0) return 1 % m;
    ll u = modpow(x, n/2, m);
    u = (u*u)%m;
    if(n%2 == 1) u = (u*x)%m;
    return u;
}

int main () {
    FASTIO
    string s;
    int n;
    cin >> s >> n;

    for(int i = 0; i < s.length(); i++) {
        if(s[i] == '9') continue;

        char largest = '.';
        int index;
        for(int j = i +1; j < min((int)s.length(), i + n + 1); j++) {
            if(s[j] > s[i] && int(s[j]) > int(largest)) {
                largest = s[j];
                index= j;
            }
        }

        if(largest != '.') {
            n -= (index-i);
            s.insert(s.begin() + i, largest);
            s.erase(s.begin() + index + 1);
        }

        cout << s << endl;
        if(n == 0) break;
    }

    cout << s << endl;

    return 0;
}

#include <bits\stdc++.h>

using namespace std;

int main()
{
    string s ;
    int k  ;
    cin >> s >> k;
    vector<string> str;
    char ch = '0' ;
    int x = 0 ;
    int start = 0 ;
    khaled :
        x = -1 ;
        ch = '0';
        int y = 0;
        bool b = 0 ;
    //cout << s <<" " << k << endl;
    for(int i =  start; i  < s.size();i++)
    {
        if(x-start == k){
            break;
        }
        if(i-start > k)
        {
            if(y>0)
                b = 1;
            else
                break;
        }
        if(s[i] >= ch)
        {
            if(s[i] == ch){
                start ++ ;
                y++;
            }
            else { start -= y ; y = 0;
                  if(b)
                  {
                      string s1 = "";
                      s1 += s[i] ;
                      s.insert(start + k - (x-start) , s1);
                      s.erase(i+1 , 1);
                      k = 0;
                  }
            }
            ch = s[i] ;
            x = i;
            //cout << ch << " " << x << " "<< start << endl;
        }
    }
    if(x == -1)
    {
        cout << s << endl;
        return 0;
    }
    //cout << k << " " << x << endl;
    string s1 = "";
    s1 += s[x] ;
    s.insert(start , s1);
    s.erase(x+1 , 1);
    //cout << s << endl;
    k -= (x-start);
    if(k < 0)
    {
        for(int i = start ; i < start+abs(k) ; i++)
            swap(s[i] , s[i+1]);
        k = 0;
    }
    if(k){
        start ++;
        goto khaled;
    }
    cout << s << endl;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
#define PI 3.14159265358979
#define eps 1e-9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		string a;
		ll k;
		cin>>a>>k;
		rep(i,a.length()){
			ll curr = a[i] - '0';
			if(curr == 9){
				continue;
			}
			repD(j,9,curr+1){
				ll coun = 0;
				repA(k,i+1,a.length()-1){
					if(a[k]-'0' == j){
						coun++;
						break;
					}
					else
						coun++;
				}
				if(coun == 0)
					continue;
				if(coun <= k){
					k-=coun;
					repD(k,i+coun,i+1){
						char p = a[k-1];
						a[k-1] = a[k];
						a[k] = p;
					}
				}
			}
		}
		cout<<a;
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<long long int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	ll;

#define mod 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define forn(i, n) for(ll i = 0; i < ll(n); ++i)
#define forv(i, n) for(int i = 0; i != int(n); ++i)
#define cases int t;  cin>>t;   while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    string s;
    int k,a[20];
    cin>>s>>k;
    int n=s.length();
    if(n==1)
    {
        cout<<s;
        return 0;
    }
    forn(i,s.length())
        a[i]=s[i]-'0';
    int j=1,count=1;
    while(k>0)
    {
        //1cout<<1;
        int flag=1;
        forn(i,n-1)
            if(a[i]<a[i+1])
            {
                flag=0;
                break;
            }
        if(flag)
            break;
        int m=a[j],p=j;
        forn(i,min(n,k)-count)
            if(m<a[j+i])
            {
                m=a[j+i];
                p=j+i;
            }
        //cout<<p;
        if(m>a[j-1])
        {
            for(int i=p;i>=j;i--)
                swap(a[i],a[i-1]);
            k-=p-j+1;
        }
        j++;count++;

   /* forn(i,n)
        cout<<a[i];
        cout<<endl;
    */}
    forn(i,n)
        cout<<a[i];
    return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <ctype.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#define File_in(input) freopen(input, "r", stdin)
#define File_out(output) freopen(output, "w", stdout)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> point;
const int ms = 1e5+10;
const int mod = 1000000007;
const ll inf = 2147483645;

bool cmp (point p1, point p2) {
  return p1.first > p2.first;
}

int main () {
    //File_in("input.txt"); File_out("output.txt");
    ios_base::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    char c = '0';
    int p = 0;
    int n = s.length();
    for (int i = 0; i < n && k > 0; i++) {
        int j = i+1;
        p = i;
        c = s[i];
        for (; j < i+k+1; j++) {
            if (j > n+1)
                break;
            if (s[j] > c ) {
                c = s[j];
                p = j;
            }
        }
        if (c > s[i]) {
            for (int x = p; x >= i-1; x--) {
                if (s[i] == c)
                    break;
                swap(s[x],s[x-1]);
                k--;
                if(!k)
                    break;
            }
        }
    }
    cout << s << '\n';
}

#include<bits/stdc++.h>
typedef long long int lli;

#define em emplace_back
#define rep(i,j,n) for(lli i=j;i<n;i++)
#define repf(i,a,j,n) for(lli i=j,a=0;i<n;i++,a++)
#define repg(i,j,n) for(int i=j;i>n;--i)
using namespace std;

void dbg(vector<long long int > v){
  for(long long int i = 0 ; i<v.size(); ++i){
   cerr<<v[i]<<" ";
  }
  cerr<<endl;
}
void prt(vector<long long int > v){
  for(long long int i = 0 ; i<v.size() ; ++i){
   cout<<v[i]<<" ";
  }
  cout<<endl;
}

void solve(){
	string s;
	cin>>s;
	lli k;
	cin>>k;
	lli i = 0;
	while(k>0&&i!=s.size()){
		// cerr<<s[i]<<" "<<s[i+1]<<" "<<i<<"\n";
		if(s[i]<s[i+1]){
			k--;
			char c = s[i];
			s[i] = s[i+1];
			s[i+1] = c;
			i = 0;
		}else{
			i++;
		}
	}
	cout<<s;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
    #endif
	solve();

	return 0;
}

#include <iostream>
#include <sstream>
#include <math.h>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

long long swap(long long n) {
	// going from left to right, find the first position where n[i] > n[i-1]
	stringstream s;
	s << n;
	string str = s.str();
	for(int i=1; i<s.str().size(); i++) {
		if(str[i]>str[i-1]) {
			char temp = str[i];
			str[i] = str[i-1];
			str[i-1] = temp;
			break;
		}
	}
//	cout << "returning " << atol(str.c_str()) << endl;
	return atol(str.c_str());
}

int main(int argc, char** argv) {
	long long n, k;
	cin >> n >> k;
	long long ans = n;
	for(int i=0; i<k; i++) {
		n = swap(n);
		ans = max(ans, n);
	}
	cout << ans << endl;
}

#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
char a[1001];
int main(){
    cin>>a;
    int k;
    cin>>k;
    int l=strlen(a);
        for(int v=0;v<l;v++){
            for(int i=v+1;i<l;i++){
                if(a[i]>a[v]){
                    int x=i;
                    while(k&&x>v){
                        char temp=a[x];
                        a[x]=a[x-1];
                        a[x-1]=temp;
                        x--;
                        k--;
                    }
                }
            if(!k)
                break;
            }
            if(!k)
                break;
        }
    cout<<a<<endl;
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[22];
    int b,flag,lena,i,t,max,maxi;
    scanf("%s%d",a,&b);
    lena=strlen(a);
    if(lena==1) {printf("%s\n",a);return 0;}
    flag=1;
    while(b)
    {
        max=-1;
        for(i=flag;i<flag+b&&i<lena;i++)
        {
            if(a[i]>max) {max=a[i];maxi=i;}
        }
        if(max==-1) break;
       // printf("%d\n",maxi);
        while(maxi!=flag&&a[maxi]>a[maxi-1])
        {
            t=a[maxi-1];
            a[maxi-1]=a[maxi];
            a[maxi]=t;
            maxi--;
            b--;
        }
           //printf("%s\n",a);break;
        if(a[flag]>a[flag-1])
        {
             t=a[flag];
            a[flag]=a[flag-1];
            a[flag-1]=t;
            b--;
        }
        flag++;
    }
    printf("%s\n",a);
    return 0;
}

#include<cstdio>
#include<cstring>
char a[20];
int main(){
    scanf(" %s",a);
    int len=strlen(a),k,t;
    scanf("%d",&k);
    if(len==1){
        printf("%s\n",a);
        return 0;
    }
    for(int i=0;i<len;i++)
        a[i]-='0';
    while(k){
        for(int i=1;i<len;i++){
            if(a[i]>a[i-1])     break;
            if(i==len-1){
                if(k%2)     t=a[len-2],a[len-2]=a[len-1],a[len-1]=t;
                k=0;
            }
        }
        for(int i=0;i<len;){
            int max=i;
            for(int j=i+1;j<=i+k && j<len;j++)
                if(a[max]<a[j])    max=j;
            if(max!=i)
                t=a[max-1],a[max-1]=a[max],a[max]=t,k--;
            else    i++;
        }
    }
    for(int i=0;i<len;i++)
        printf("%d",a[i]);
    printf("\n");
    return 0;
}

  #pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;

  void solve(){
	  string s;
	  int k;
	  cin >> s >> k;
	  int n = s.size();
	  string k1 = s;
	  sort(all(k1));
	  reverse(all(k1));
	  for(int i=0;i<n;i++){
	  	  if(k==0)break;
			if(s[i]!=k1[i]){
				int mx_indx=-1;
				char mx=s[i];
				for(int j=i+1;j<=min(n-1,i+k);j++){
					if(mx < s[j]){
						mx = s[j];
						mx_indx = j;
					}
				}
				if(mx>s[i]){
					for(int j=mx_indx;j>i;j--){
						swap(s[j],s[j-1]);
						k--;
					}
				}
				deb(s);
				deb(k);
			}
	  }
	  if(k){
	 	for(int i=1;i<n && k;i++){
	  		if(s[i-1] < s[i]){
	  			swap(s[i-1],s[i]);
	  			k--;
	  		}
	    }
	  }
	  cout << s;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

//#include<bits/stdc++.h>
//#include <fstream>
#include<iostream>
#include<cmath>
#include<time.h>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#define P_ M_PI
#define maxn 10000009
#define INF 1000000007
#define LLINF 1000000000000000007
#define mp(x,y) make_pair(x,y)
#define ff first
#define cs(x,y) cout<<"Case "<<y<<": "<<x<<endl;
#define ss second
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define ppb() pop_back()
#define tr(i, c) for(typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define rand srand( (unsigned)time( NULL ) ); int randomNumber = rand()%1001 + 1;
using namespace std;
/*
ifstream cin("file.in");
ofstream cout("file.out");
*/
vector <int> l;
long long a,b,m,n,k;
int main()
{
   cin>>a>>b;
   while(a>0)
   {
     l.pb(a%10);
     a/=10;
   }
   reverse(l.begin (),l.end ());
   while (b>0 && m<l.size()-1)
   {
   	  n=l[m];
   	  k=0;
      for(int i=m+1;i<l.size ();i++)
      {
	    if(i-m<=b && n<l[i])n=l[i],k=i;
	  }

	   if(l[m]!=n)
       {
       	 b-=(k-m);
	     for(int i=k;i>m;i--)
	         l[i]=l[i-1];
	       l[m]=n;
	   }
	   m++;
	}
     if(b>0 && b%2==1 && l.size() >1)
       swap(l[l.size ()-1],l[l.size()-2]);
     for(int i=0;i<l.size ();i++)
	  		cout<<l[i];

return 0;
}