A, B = input().split() N = max(len(A), len(B)) AA = f"{A:0>{N}}" BB = f"{B:0>{N}}" for a, b in zip(AA, BB): if a == b: continue a = int(a) b = int(b) if a == 4 and b == 7 or a == 7 and b == 4: a, b = b, a if a > b: print(A) exit() elif a < b: print(B) exit()