L = input().split() A, B = [X.zfill(10) for X in L] for I, J in zip(A, B): if I == J: continue else: if I in '47' and J in '47': I, J = J, I print(L[I < J]) break