A, B = map(str, input().split()) if len(A) > len(B): print(A) elif len(A) < len(B): print(B) else: for a, b in zip(A, B): if a == '4' and b == '7': print(A) exit() elif a == '7' and b == '4': print(B) exit() elif int(a) > int(b): print(A) exit() elif int(a) < int(b): print(B) exit()