import java.awt.*;
import java.util.Scanner;
import java.io.*;


public class P2
{
  
  public static void main (String[] args)throws IOException
  {
    FileReader fr;
    BufferedReader br;
    String line;
    FileWriter fw;
    PrintWriter writer;
    int[] numbers = new int[5];

    int count = 0;
    boolean found = false;
    
    
    
    try
    {
      fr = new FileReader ("DATA2.txt");
      br = new BufferedReader (fr);
        fw = new FileWriter ("OUT2.txt ", true);
      writer = new PrintWriter (fw);
      
      while ((line = br.readLine ()) != null)
      {
        numbers[count] = Integer.parseInt (line);
        count++;
      }
      count = 0;
      for(int i = 0; i < numbers.length; i ++)
      {
        int n = numbers[i];
        found = false;
        count = 0;
        while(found == false)
        {
          if((Math.pow(2,count) > n && Math.pow(2,count - 1) < n) || n == Math.pow(2,count) )
          {
            System.out.println(n);
            found = true;
            if(n == Math.pow(2,count))
            {
              writer.println ((int)(Math.pow(2,count)));
            }
            else
            {
              if((Math.pow(2,count) - n) > (n - Math.pow(2,count - 1)))
              {
                writer.println ((int)(Math.pow(2,count - 1)));
                
              }
              else
              {
                writer.println ((int)(Math.pow(2,count)));
              }
            }
          }
          else if (n == 0)
          {
            writer.println(1);
            found = true;
          }
          count++;
        }
      }
         
      
      writer.close ();
      
      
      br.close ();
    }
    catch (IOException e)
    {
    }
    catch (NumberFormatException e)
    {
    }
    
  }
}
