import sequtils, strutils let s1 = stdin.readLine ns = s1.toSeq.mapIt ($it).parseInt var l, r: int s2 = s1 for i in 0 ..< s1.high: let max = (ns[i..^1]).max if max == ns[i]: continue l = i r = i.succ for j in i.succ .. s1.high: if ns[j] >= ns[r]: r = j swap(s2[l], s2[r]) break echo s2