N = int(input(), 16) cnt = [0] * 10 while N: cnt[N % 8] += 1 N //= 8 M = max(cnt) ans = [] for i in range(10): if cnt[i] == M: ans.append(i) print(*ans)