loop do
  n = gets.to_i
  break if n==0
  s = n.to_s(8)
  for i in 0..(s.length-1)
    c = s[i]
    if '4'<=c
      c.next!
    end
    if '6'<=c
      c.next!
    end
    print c
  end
  print "\n"
end