A, B = input().split() def f(x): return x.replace("4", "t").replace("7", "4").replace("t", "7") if int(f(A)) > int(f(B)): print(A) else: print(B)