a, b = gets.chomp.split(' ') a_size = a.size b_size = b.size if a_size > b_size puts a exit elsif a_size < b_size puts b exit end 0.upto(a_size - 1) do |i| if a[i] == '4' && b[i] == '7' puts a exit elsif a[i] == '7' && b[i] == '4' puts b exit elsif a[i] > b[i] puts a exit elsif a[i] < b[i] puts b exit end end puts a