""" A, B = map(int, input().split()) if A + B > A * B: print("S") elif A + B < A * B: print("P") else: print("E") """ import random def gcd(a, b): if a < b: a, b = b, a if a % b == 0: return b else: return gcd(b, a % b) #A, B = map(int, input().split()) #print(gcd(A, B)) N = input() """ cnt = {} for c in N: if not c in cnt: cnt[c] = 1 else: cnt[c] += 1 """ """ num = "0123456789" mn = "" for n in num: if n in cnt: for _ in range(cnt[n]): mn += n """ #print(int(mn)) first = True for _ in range(1000): if first: #print("AAA") nnn = N ans = int(nnn) first = False else: #print("BBB") ransu = random.randint(0, len(N)-2) if ransu >= 0: #print("VCVV") #print("N = " + N); #print("ransu = " + str(ransu)) #nn = N[0:ransu-1] + N[ransu+1:ransu+1] + N[ransu:ransu] + N[ransu+2:-1] if ransu == 0: nn = N[ransu+1] + N[ransu] + N[ransu+2:-1] if ransu == 1: nn = N[0] + N[ransu+1] + N[ransu] + N[ransu+2:-1] else: nn = N[0:ransu-1] + N[ransu+1] + N[ransu] + N[ransu+2:-1] #print("aaa" + nn + "aaa") ans = gcd(ans, int(nn)) print(ans)