public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		long n=in.nextLong();
		int c=in.nextInt();
		char[] result=Long.toString(n).toCharArray();
		int starting = 0;
		for(int i=0;i<c;){
			if(starting>=result.length) break;
			int index = findLargestIndex(result, c-i+1, starting);
			swapFromJtoI(result, starting, index);
			i+=index-starting;
			starting++;
//			System.out.println(i);
		}
		
		System.out.println(result);
	}