fun main(args: Array) { val n = readLine()!!.map { it.toString().toInt() }.toMutableList() val a = mutableListOf>().also { it.add(n) } for(i in (0 until n.lastIndex)) { for(j in (1 .. n.lastIndex)) { val tmp = n.toMutableList() tmp[i] = n[j] tmp[j] = n[i] a.add(tmp) } } println(a.map { it.joinToString("") }.sortedDescending().first()) }