let rec repl () =
  let s = read_line () in
  if s = "0" then ()
  else begin
    let sum = ref 0 in
    String.iter (fun c -> sum := !sum + (Char.code c) - (Char.code '0')) s;
    Printf.printf "%d\n" !sum;
    repl ()
  end

let () =
  try repl () with End_of_file -> ()