n = input() if len(set(n)) == 1: print(n) exit() tot = sum(map(int, n)) if tot % 9 == 0: ans = 9 elif tot % 3 == 0: ans = 3 else: ans = 1 if all(int(x) % 4 == 0 for x in n): ans *= 4 elif all(int(x) % 2 == 0 for x in n): ans *= 2 if all(int(x) % 5 == 0 for x in n): ans *= 5 print(ans)