A, B = gets.rstrip.split.map(&:chars) if A.size != B.size puts A.size > B.size ? A.join : B.join else 0.upto(A.size - 1) do | i | if (A[i]=='4' && B[i]=='7') || (A[i]=='7' && B[i]=='4') puts A[i] < B[i] ? A.join : B.join exit else if A[i] < B[i] puts B.join exit elsif A[i] > B[i] puts A.join exit else #A[i] == B[i] next end end end end