unittest
{
	assert( [ "111" ].parse.expand.solve == 111 );
	assert( [ "112" ].parse.expand.solve == 222 );
	assert( [ "750" ].parse.expand.solve == 777 );
}



import std.algorithm;
import std.conv;
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 )
{
	return [ 111, 222, 333, 444, 555, 666, 777, 888, 999 ].find!( ( a, b ) => b <= a )( n ).front;
}
