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()) for k,v in sorted(c.items(), key=lambda x: -x[1]): if v == mx: print(k, end=' ') print(end='\n')