def sw(n) n.to_s.chars.map{|c| case c when "4" then "7" when "7" then "4" else c end }.join.to_i end def main(a, b) p sw(a) < sw(b) ? b : a end if __FILE__ == $0 main(gets.split(" ").map(&:to_i)) # main(4, 7) end