(* O(n log n) *)
let n = read_int () in
let rec sum n = if n <= 0 then 0 else n mod 10 + sum (n / 10) in
let ans = ref max_int in
for a = 1 to n - 1 do
  ans := min !ans @@ sum a + sum (n - a)
done;
Printf.printf "%d\n" !ans