import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int n = sc.nextInt();
            LinkedList<Integer> now = new LinkedList<>();
            for(int i = 1; i <= n; i += 2) {
                now.addLast(i);
            }
            while(now.size() != 1) {
                LinkedList<Integer> pre = new LinkedList<>();
                while(!now.isEmpty()) {
                    now.removeFirst();
                    if(now.isEmpty()) {
                        break;
                    }
                    pre.addLast(now.removeFirst());
                }
                now = pre;
            }
            System.out.println(now.getFirst());
        }
    }
}