import itertools def f(n): l = [] a, b = 0, 2 while b * b <= n: if n % b == 0: n //= b l += [b] else: b += 1 + a a = 1 if n > 1 : l += [n] return [1] + l def g(a, b): r = [] for i in a: if b % i == 0: r += [i] b //= i return r def main(): l = input() s = set([]) a = 0 for i in itertools.permutations(l, len(l)): a = int(''.join(i)) s.add(a) a = f(a) for i in s: a = g(a, i) ans = 1 for i in a: ans *= i print(ans) if __name__ == '__main__': main()