A,B=gets.split l=[A,B].map &:size r=A.to_i<=>B.to_i l.uniq[1]||l[0].times.any?{|i|[A[i],B[i]].sort==[?4,?7]&&r=B[i]<=>A[i]} $><<[0,A,B][r]