n = input().strip() # Check if all digits are the same if len(set(n)) == 1: print(n) else: sum_digits = sum(int(c) for c in n) sum_factor = 9 if sum_digits % 9 == 0 else (3 if sum_digits % 3 == 0 else 1) # Check if all digits are even all_even = all(int(c) % 2 == 0 for c in n) if all_even: all_048 = all(c in {'0', '4', '8'} for c in n) k = 2 if all_048 else 1 else: k = 0 # Check if all digits are 0 or 5 all_0_or_5 = all(c in {'0', '5'} for c in n) m = 1 if all_0_or_5 else 0 gcd_value = sum_factor * (2 ** k) * (5 ** m) print(gcd_value)