from collections import Counter n = int(input(), base=16) h = oct(n) cnt = Counter(h[2:]) ma = 0 for k, v in cnt.items(): if v > ma: ma = v ans = [] for k, v in cnt.items(): if v == ma: ans.append(int(k)) ans.sort() print(*ans)