unittest
{
	assert( [ "119" ].parse.expand.solve == 991 );
	assert( [ "999" ].parse.expand.solve == 111 );
}



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!( dchar[] );
	return tuple( n );
}

auto solve( dchar[] n )
{
	auto r = 0L;
	foreach( c; n )
	{
		r *= 10;
		auto d = ( c - '0' ).to!long;
		switch( d )
		{
			case 1 : d = 9; break;
			case 9 : d = 1; break;
			default:        break;
		}
		r += d;
		
	}
	return r;
}
