import java.util.*;
import java.io.*;
import java.awt.Point;
import java.util.regex.*;
import java.math.*;
import java.text.*;

/**
 *
 * @author James Brocklebank
 */
public class _2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader fin = new BufferedReader(new FileReader("DATA2.txt"));
        PrintWriter fout = new PrintWriter(new FileWriter("OUT2.txt"));
        int[] powers = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072};


        for (int i = 0; i < 5; i++) {
            int x = Integer.parseInt(fin.readLine());

            if (x == 0) {
                fout.println(1);
                continue;
            }


            int idxSmallest = 0;

            // find the first number that is smaller than x
            while (powers[idxSmallest] < x) {
                idxSmallest++;
            }

            int idxLargest = powers.length-1;
            while(powers[idxLargest]>x) {
                idxLargest--;
            }
            //System.out.println(powers[idxLargest] + " " + powers[idxSmallest]);

            int nLarge = Math.abs(powers[idxLargest]-x);
            int nSmall = Math.abs(powers[idxSmallest]-x);

            if(nLarge > nSmall) {
                fout.println(powers[idxSmallest]);
            } else if(nLarge < nSmall) {
                 fout.println(powers[idxLargest]);
            } else {
                 fout.println(Math.max(powers[idxLargest],powers[idxSmallest]));
            }
        }

        fout.close();
        fin.close();
    }
}

