object Main {
  def main(args: Array[String]) {
    val factor = scala.io.StdIn.readLine.split("")
    factor.foreach { c =>
        if(c == "1") {
          print("9")
        }
        else if(c == "9") {
            print("1")
        }
        else {}
    }
    println()
  }
}
