n = gets.chomp m = [] result = "" num = n.to_s.split("") num.each do |i| m << i.to_i end num2 = m.sort_by{|i| -i} num2.each do |i| result << i.to_s end p result.to_i