x = int(input(), 16) if x == 0: print(0) exit() hist = [0] * 8 while x: hist[x % 8] += 1 x //= 8 mx = max(hist) print(*(i for i in range(8) if hist[i] == mx))