n = input().strip()

# Convert each hex character to 4-bit binary string
binary_str = ''.join(format(int(c, 16), '04b') for c in n)

# Adjust the binary string to have length multiple of 3 by prepending zeros
length = len(binary_str)
remainder = length % 3
if remainder != 0:
    pad = (3 - remainder) % 3
    binary_str = '0' * pad + binary_str

# Split into chunks of 3 bits and convert to octal digits
oct_digits = []
for i in range(0, len(binary_str), 3):
    chunk = binary_str[i:i+3]
    digit = int(chunk, 2)
    oct_digits.append(str(digit))

oct_str = ''.join(oct_digits)

# Remove leading zeros, but ensure at least one zero remains if needed
oct_str = oct_str.lstrip('0')
if not oct_str:
    oct_str = '0'

# Count the occurrences of each digit
from collections import defaultdict
counts = defaultdict(int)
for c in oct_str:
    counts[c] += 1

# Find the maximum count and collect all digits with that count
max_count = max(counts.values(), default=0)
max_digits = [d for d, cnt in counts.items() if cnt == max_count]

# Sort the digits in ascending numerical order
max_digits.sort(key=lambda x: int(x))

# Output the result
print(' '.join(max_digits))