import java.io.*;
import java.util.*;

public class Meh {

    public static void main(String[] args) throws IOException{
        Scanner in = new Scanner (new FileReader ("DATA3.txt"));
        PrintWriter out = new PrintWriter (new FileWriter ("OUT3.txt"));

        for (int c = 0; c < 5; c++) {
            int x = in.nextInt();
            String y = Integer.toBinaryString(x);
            String z = "";
            boolean a = true;
            String b = null;b = new StringBuffer (z).reverse().toString();

            if (Math.log(x) / Math.log(2) % 1 == 0)
               out.println((int)Math.pow(2, (Math.log(x) / Math.log(2)) + 1));

            else {
                for (int i = y.length() - 1; i >= 0; i--) {
                    if ((i != 0) && (a) && (y.charAt(i) == '1') && (y.charAt(i - 1) == '0')) {
                        z += "0";
                        z += "1";
                        i--;
                        a = false;
                    }

                    else {
                        z += y.charAt(i);
                    }
                }
                
                if (a) {
                    z = y.charAt(0) + "0" + y.substring(1);
                    b = z;
                }

                else b = new StringBuffer (z).reverse().toString();
                out.println(Integer.parseInt(b, 2));
            }
        }

        out.close();
    }
}

