import strutils, sequtils, algorithm, math var n = readLine(stdin).parseInt() nStr = n.intToStr() nStrTmp: string maxV = n for i in countup(0, nStr.len() - 2): for j in countup(1, nStr.len() - 1): nStrTmp = nStr nStrTmp[i] = nStr[j] nStrTmp[j] = nStr[i] maxV = max(maxV, nStrTmp.parseInt) echo(maxV)