unittest
{
	assert( [ "1024" ].parse.expand.solve == 2020 );
	assert( [ "0" ].parse.expand.solve == 0 );
	assert( [ "1000000000" ].parse.expand.solve == 2000000000 );
}



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 x = input.front.to!( long );
	return tuple( x );
}

auto solve( long x )
{
	return ( x / 500 ) * 1000 + ( x % 500 / 5 ) * 5;
}
