let n = read_int () in
let ans = ref max_int in
let rec sum n = if n <= 0 then 0 else n mod 10 + sum (n / 10) in
for a = 0 to 9 do
  for b = 0 to 9 do
    for c = 0 to 9 do
      for d = 0 to 9 do
        for e = 0 to 9 do
          let a_sum = a + b + c + d + e in
          if a_sum > 0 then
            let a' = 10000 * a + 1000 * b + 100 * c + 10 * d + e in
            if a' < n then ans := min !ans @@ a_sum + sum (n - a')
        done
      done
    done
  done
done;
Printf.printf "%d\n" !ans