s=gets.chop.chars t=s.sort f=s.size-1 (0..f).map{|i| if s[i]!=t[f] x=s.rindex t[f] y=s[i] s[i]=t[f] s[x]=s[i] break end } $><