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();
            int cntMax = 1, ans = 1;
            n += 1;
            for(int i = 2; i < n; i++) {
                int cnt = Integer.bitCount(i);
                if(cnt > cntMax) {
                    cntMax = cnt;
                    ans = i;
                }
            }
            System.out.println(ans);
        }
    }
}