from collections import Counter N = list(input()) oct_count = Counter() while N: value_str = "" for _ in range(3): value_str += N.pop() if not N: break oct_count += Counter(oct(int(value_str, base=16))[2:]) 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))