A, B = input().split() ans = A Al, Bl = len(A), len(B) if Al < Bl: ans = B if Al == Bl: for i in range(Al): if A[i] == '7' and B[i] == '4': ans = B elif (A[i] != '4' or B[i] != '7') and A[i] < B[i]: ans = B print(ans)