A,B = map(str,input().split()) A1 = A.replace('7','!') A1 = A.replace('4','?') A1 = A.replace('?','7') A1 = A.replace('!','4') B1 = B.replace('7','!') B1 = B.replace('4','?') B1 = B.replace('?','7') B1 = B.replace('!','4') if int(A1) < int(B1): print(B) else: print(A)