def main(): A, B = input().split() a, b = [x.zfill(10) for x in (A, B)] ans = -1 for i in range(10): if a[i] == b[i]: continue if a[i] == '4' and b[i] == '7': ans = A elif a[i] == '7' and b[i] == '4': ans = B elif a[i] > b[i]: ans = A else: ans = B break print(ans) main()