n = str(input()) n = int(n,16) n = oct(n) #print(n) n = n[2:] #print(n) from collections import Counter C = Counter(n) M = max(list(C.values())) C = list(C.items()) ans = [] for k, v in C: if v == M: ans.append(k) ans.sort() print(*ans)