import java.util.*;
import java.io.*;
class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Deque<Integer> deque = new LinkedList<Integer>();
for(int i =1 ; i <= N ; i ++) {
deque.addLast(i);
}
while(deque.size() != 1) {
deque.pollFirst();
deque.offerLast(deque.pollFirst());
}
System.out.println(deque.pollFirst());
}
}
입력을 하나만 받는데도 scanner보다 빠르다.