Convert = [0,1,2,3,5,7,8,9]

def solve n
  result = Array.new
  while n > 0 do
    l = n % 8
    n = n / 8
    result.push(Convert[l])
  end
  result.reverse.join()
end

while (n = $stdin.gets.to_i) != 0 do
  puts solve(n)
end