        const
                tfi='DATA2.txt';
                tfo='OUT2.txt';
                maxn=18;
        var
                mu      :       array[0..maxn] of longint;
                n       :       longint;
        procedure tao;
            var
                i       :       longint;
            begin
                fillchar(mu,sizeof(mu),0);
                mu[0]:=-1000;
                mu[1]:=1;
                for i:=2 to 18 do mu[i]:=mu[i-1]*2;
            end;
        procedure xuly;
            var
                i       :       longint;
            begin
                for i:=1 to 18 do
                 begin
                   if mu[i]=n then
                      begin
                          writeln(mu[i]);
                          exit;
                      end;
                   if mu[i]>n then
                      begin
                          if mu[i]-n<=n-mu[i-1] then
                              writeln(mu[i])
                          else writeln(mu[i-1]);
                          exit;
                      end;
                 end;
            end;
        begin
            assign(input,tfi);reset(input);
            assign(output,tfo);rewrite(output);
            tao;
            while not eof do
                begin
                   readln(n);
                   xuly;
                end;
            close(input);
            close(output);
        end.
