Akela, the great grey lone wolf, became the leader of the pack thanks to his strength and cunning. For twelve years, the Lone Wolf led the pack to and from the hunt, and during all that time, not a single wolf was caught in a trap.
Akela grew old and weak, and now the lame tiger Shere Khan made friends with the younger wolves, who often followed him. Akela would never have allowed this if his former strength had let him assert his authority as before.
Over the years, Akela began to forget parts of the Law of the Jungle. No, he could not break it, for the Law had long become part of his instincts, and he still remembered its checksum exactly.
So the young opposition wolves, together with Shere Khan, decided to make amendments and additions to the Law—in other words, to expand and supplement it. One can only guess why they needed this, but fortunately, the amendments were rejected by Hathi himself, so the Jungle could sleep peacefully.
Yet it is interesting to wonder what the main Law would look like with the amendments and additions of Shere Khan's opposition wolves, if the checksum remained the same.
A natural number (1 \leq n \leq 10^{100}) — the Law of the Jungle.
Print the smallest natural number m > n having the same checksum (sum of digits) as — the version of the Law of the Jungle as envisioned by the opposition wolves led by Shere Khan.
Example 1
Example 2