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