s=[int(i) for i in input()] n=reduce(lambda a,b:a+b,s) if s.count(s[0])==len(s): print(str(s[0])*len(s)) elif n%36==0: print(36) elif n%9==0: print(9) elif n%3==0: print(3) else: print(1)