A, B = input().split() a = len(A) b = len(B) c = 0 if a > b: c = A elif a < b: c = B else: for i in range(a): if A[i] == '4' and B[i] == '7': c = A break elif A[i] == '7' and B[i] == '4': c = B break elif A[i] > B[i]: c = A break elif A[i] < B[i]: c = B break print(c)