""" https://yukicoder.me/problems/no/443 桁が多い場合はほとんど1になりそうなんだよな 小さい場合は無作為shuffleでも効きそう 2222122 みたいなのに弱いか? 偶数対策だけしておくべきか """ import math import random import sys from collections import defaultdict # 制限を解除(無制限にしたい場合は0を指定) sys.set_int_max_str_digits(0) N = list(input()) dic = defaultdict(int) for c in N: dic[int(c)] += 1 import time start = time.time() ans = 0 while True: random.shuffle(N) X = int("".join(N)) ans = math.gcd(X,ans) # 0.8秒経ったらループを抜ける if time.time() - start > 0.8: break if dic[1]+dic[3]+dic[5]+dic[7]+dic[9] > 0: while ans % 2 == 0: ans //= 2 print (ans)