let sum x =
  let c = ref 0 in
  Bytes.iter (fun x -> c := !c + Char.code x - Char.code '0') x;
  !c

let () =
  let rec loop () =
    let x = Scanf.scanf "%s\n" (fun x -> x) in
    if x = "0" then ()
    else (Printf.printf "%d\n" (sum x); loop ()) in
  loop ()