
import std.algorithm.comparison;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto x = readln.strip.to!int;
	auto result = 1;
	
	foreach( int b; 1 .. x )
	{
		foreach( int p; 2 .. x )
		{
			auto bp = b ^^ p;
			if( x < bp ) break;
			
			result = max( result, bp );
		}
	}
	
	writeln( result );
}
