import scala.io.StdIn.readInt

object Main extends App {
  def replace(i:Char) = i match {
    case '4' => '5'
    case '5' => '7'
    case '6' => '8'
    case '7' => '9'
    case x => x
  }

  Iterator.continually(readInt).takeWhile( _ != 0 ).foreach { n=>
    println("%o".format(n).map{replace})
  }
}