let sum_of_digit str =
  let len = String.length str in
  let rec iter i sum = match len-i with
    | 0 -> sum
    | _ -> iter (i+1) ((int_of_char str.[i] - 48) + sum )
  in iter 0 0

let () =
  let rec loop () =
    match read_line () with
    | "0" -> ()
    | n ->
      Printf.printf "%d\n" (sum_of_digit n);
      loop ()
  in loop ()