from collections import Counter S = int(input(), 16) T = oct(S)[2:] CNT = [0] * 8 for x in T: CNT[int(x)] += 1 ANS = [] for i in range(8): if CNT[i] == max(CNT): ANS.append(i) print(*ANS)