A,B = map(str,input().split()) if len(A) > len(B): print(A) elif len(A) < len(B): print(B) i = 0 while i < len(A): if A[i] == '4': if B[i] == '7': print(A) break if A[i] == '7': if B[i] == '4': print(B) break if A[i] > B[i]: print(A) break elif A[i] < B[i]: print(B) break i = i+1