import sys from collections import Counter input = lambda: sys.stdin.readline().rstrip() ################## n = int(input(), 16) c = Counter(list(str(oct(n)[2:]))) mx = max(c.values()) ans = [] for k,v in c.items(): if v == mx: ans.append(k) print(*sorted(ans))