s=oct(int(input(), 16)) c=[0]*8 for i in range(2, len(s)): x=int(s[i]) c[x]+=1 m=max(c) for i in range(8): if c[i]==m: print(i, end=' ') print()