s=gets.chop.chars;i=~0;s.any?{|c|t=s[i+=1..-1].max;c==t||(s[i],s[s.rindex t]=t,c)};$><