using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; public static class P { public static void Main() { var s = Console.ReadLine().ToArray(); var max = s.Max(x => x); var firstNotMaxPlace = s.TakeWhile(x => x == max).Count(); var lastMaxPlace = s.Length - 1 - s.Reverse().TakeWhile(x => x != max).Count(); if (firstNotMaxPlace < lastMaxPlace) { var tmp = s[firstNotMaxPlace]; s[firstNotMaxPlace] = s[lastMaxPlace]; s[lastMaxPlace] = tmp; } Console.WriteLine(string.Join("", s)); } }