program main
  implicit none
  integer :: n, i
  character(3) :: s, t
  read(*, *) n
  write(s, "(i3)") n
  t(:) = s(:)
  do i = 1, 3
    if (s(i:i) == "1") then
      t(i:i) = "9"
    else if (s(i:i) == "9") then
      t(i:i) = "1"
    end if
  end do
  write(*, "(a)") t
end program main
