import sys #sys.setrecursionlimit(10 ** 6) INF = float('inf') #10**20,2**63に変えるのもあり MOD = 10**9 + 7 MOD2 = 998244353 from collections import defaultdict def solve(): def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LC(): return list(input()) def IC(): return [int(c) for c in input()] def MI(): return map(int, sys.stdin.readline().split()) Num = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15} N = LC() N.reverse() DecN = sum(Num[n] * 16 ** i for i, n in enumerate(N)) #print(DecN) OctN = [] # 10進から8進へ if (DecN == 0): OctN.append(0) while DecN: DecN, R = divmod(DecN, 8) OctN.append(R) num = defaultdict(lambda:0) for o in OctN: num[o]+=1 MAX = max(list(num.values())) Ans = [] for n in range(10): if num[n] == MAX: Ans.append(n) Ans.sort() print(*Ans) return solve()