import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
public class baekjoon2164 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static int N,temp;
static Queue<Integer> q = new LinkedList<>();
public static void main(String args[])throws IOException{
N = Integer.parseInt(br.readLine());
for(int i=1;i<=N;i++){
q.add(i);
}
for(int i=0;i<N-1;i++){
q.remove();
temp = q.peek();
q.remove();
q.add(temp);
}
System.out.println(q.peek());
}
}
Queue에대한 문제였다. 오랜만에 풀어봄