import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Queue<Integer> q = new LinkedList<>();
for(int i=1; i<=N; i++) {
q.offer(i); // 큐에 값 삽입
}
while(q.size() > 1) {
q.poll(); // 맨 앞에 값 버림
q.offer(q.poll()); // 맨 앞에 값 버림 & 버린 값을 맨 뒤에 삽입
}
System.out.println(q.poll());
}
}