unittest
{
	assert( [ "2" ].parse.expand.solve == 3 );
	assert( [ "4" ].parse.expand.solve == 7 );
	assert( [ "1000000000000" ].parse.expand.solve == 1099511627775 );
}



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

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

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

long solve( long h )
{
	if( h == 0 ) return 0L;
	else         return 1L + solve( h / 2 ) * 2;
}
