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