import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine()

    out.println(
      n
        .replace('1', 'X')
        .replace('9', '1')
        .replace('X', '9')
    )

    out.flush()
  }
}
