until (n = gets.chomp) == "0"
  if n.chr == "-"
    n.slice!(0)
    head = nil
  else
    head = n.slice!(-1).to_i
  end
  n.reverse!

  result = []
  until n.empty?
    result << 10 - n.slice!(0).to_i
    result << 1 + n.slice!(0).to_i
  end
  (0...result.size).each do |i|
    next if result[i] < 10
    result[i] -= 10
    result[i + 1] = 0 unless result[i + 1]
    result[i + 2] = 0 unless result[i + 2]
    if result[i + 1] > 0
      result[i + 1] -= 1
    else
      result[i + 1] += 9
      result[i + 2] += 1
    end
  end

  result.unshift(head) if head
  p (result.reverse*"").to_i
end