let rec f() =
  let a = Scanf.scanf "%s\n" (fun s -> s) in 
  let n = String.length a in
  let as_ = Array.make n '0' in
  if a <> "0" then
    begin
      for i = 0 to (n-1) do
        as_.(i) <- a.[i]
      done;
      Array.map int_of_char as_
      |> Array.map (fun x -> x - 48)
      |> Array.fold_left (+) 0 
      |> Printf.printf "%d\n";
      f()
    end ;;
f();;
