from collections import Counter N = list(input()) oct_count = Counter() zeros = 0 while N: oct_count[0] += zeros value_str = "" for _ in range(3): value_str += N.pop() if not N: break oct_num = oct(int(value_str, base=16))[2:] oct_count += Counter(oct_num) zeros += 4-len(oct_num) max_count = max(oct_count.values()) ans = [] for key, value in oct_count.items(): if value == max_count: ans.append(int(key)) print(*sorted(ans))