import sys input = sys.stdin.readline S=input().strip() ANS=0 x=0 for i in range(len(S)-1,-1,-1): s=ord(S[i])-65+10 ANS+=pow(16,x)*s x+=1 #print(ANS) X=[] while ANS!=0: X.append(ANS%8) ANS//=8 #print(X) C=[0]*8 for x in X: C[x]+=1 MAX=max(C) for i in range(8): if C[i]==MAX: print(i,end=" ")