a, b = input().split() c = int(a.replace('4', '8')) d = int(b.replace('4', '8')) print([a, b][c < d])