unittest
{
	assert( [ "1900" ].solve == 100 );
	assert( [ "3000" ].solve == 0 );
}



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

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	n %= 1000;
	if( n == 0 ) return 0L;
	else         return 1000 - ( n % 1000 );
}
