def solve(a: str, b: str): if len(a) != len(b): return b if len(b) > len(a) else a else: for (x, y) in zip(map(int, a), map(int, b)): if x == 4 and y == 7 or (not x == 7 and y == 4) and x > y: return a elif x == 7 and y == 4 or x < y: return b a, b = input().split() print(solve(a, b))