N=input() T={x:i for i,x in enumerate("0123456789ABCDEF")} X=0 for n in N[::-1]: X=16*X+T[n] Z=oct(X) Y=[0]*8 for z in Z[2:]: Y[int(z)]+=1 alpha=max(Y) print(*[i for i in range(8) if Y[i]==alpha])