unittest
{
	assert( [ "7" ].parse.expand.solve == 4 );
	assert( [ "32" ].parse.expand.solve == 32 );
	assert( [ "1" ].parse.expand.solve == 1 );
	assert( [ "100" ].parse.expand.solve == 64 );
}



import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ri = -1L;
	auto rd = -1L;
	foreach( i; 1 .. n + 1 )
	{
		auto d = memoize!div( i );
		if( rd < d )
		{
			ri = i;
			rd = d;
		}
	}
	
	return ri;
}

long div( long n )
{
	if( n % 2 != 0 ) return 0;
	else             return 1 + memoize!div( n / 2 );
}
