fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    var minSum = Int.MAX_VALUE
    for (a in 1 until n) {
        val b = n - a
        val sum = sum(a) + sum(b)
        if (sum < minSum) {
            minSum = sum
        }
    }
    println(minSum)
}

private fun sum(n: Int): Int {
    var sum = 0
    var v = n
    while (v > 0) {
        sum += v % 10
        v /= 10
    }
    return sum
}