a,b=gets.split.map{|i|'%020d'%i} z=x<=>y a.zip(b).any?{|c|c.sort==[?4,?7]?R=-z:z!=0?R=z:p};$><<[0,a,b][R].to_i