A, B = input().split() def compare_custom(a_str, b_str): # Check if the lengths differ len_a, len_b = len(a_str), len(b_str) if len_a != len_b: return a_str if len_a > len_b else b_str # Compare each digit from left to right for a_digit, b_digit in zip(a_str, b_str): if a_digit == b_digit: continue # Handle 4 and 7 cases if (a_digit == '4' and b_digit == '7'): return a_str elif (a_digit == '7' and b_digit == '4'): return b_str else: # Standard comparison for other digits return a_str if a_digit > b_digit else b_str # The two numbers are equal (impossible as per problem constraints) return a_str result = compare_custom(A, B) print(result)