import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  println(String.copyValueOf(sc.next.toCharArray.map {
    case '1' => '9'
    case '9' => '1'
    case n => n
  }))
}
