n = int(input()) q = deque([i for i in range(1, n+1)]) while(len(q) > 1): q.popleft() move_num = q.popleft() q.append(move_num) print(q[0])