def read_inputs
  numbers = []
  loop do
    x = gets.chomp
    case x
      when "0" then break
      else numbers << x
    end
  end
  numbers
end

numbers = read_inputs
puts numbers.map{|x| x.split("").map(&:to_i).inject(:+)}.join("\n")