import random import fractions s = input() g = int(s) for i in range(10000): t = int(''.join(random.sample(s ,len(s)))) g = fractions.gcd(g,t) print(g)