import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto n = readln.split[0].to!int;
	auto n1 = n/100, n2 = (n - n1*100)/10, n3 = (n - n1*100 - n2*10);
	if (n1 == 1) n1 = 9; else if (n1 == 9) n1 = 1;
	if (n2 == 1) n2 = 9; else if (n2 == 9) n2 = 1;
	if (n3 == 1) n3 = 9; else if (n3 == 9) n3 = 1;
	writeln(n1*100 + n2*10 + n3);
}
