A, B = gets.split L = [A.length, B.length].max sa = A.rjust(L, "0") sb = B.rjust(L, "0") res = catch(:ok) do for i in 0...L do na = sa[i].to_i nb = sb[i].to_i case when na == 4 && nb == 7 then throw :ok, A when na == 7 && nb == 4 then throw :ok, B when na > nb then throw :ok, A when na < nb then throw :ok, B end end end puts res