c = [0] * 8 S = input()[::-1] orda = ord('A') N = len(S) for i in range(N // 3 + 1): n = 0 for j in range(i * 3, min(i * 3 + 3, N)): n = n * 16 + ord(S[j]) - orda + 10 if i < N // 3: for _ in range(4): c[n % 8] += 1 n //= 8 else: while n: c[n % 8] += 1 n //= 8 mx = max(c) ans = [] for i in range(8): if c[i] == mx: ans.append(i) print(*ans)