let c0 = int_of_char '0' let c9 = int_of_char '9' let solve str = let lstr = String.length str in let rec solve' idx result = if idx >= lstr then result else let c = int_of_char str.[idx] in let nextResult = if c0 <= c && c <= c9 then result + c - c0 else result in solve' (idx + 1) nextResult in solve' 0 0 let () = let s = read_line () in solve s |> string_of_int |> print_endline