fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var min = Integer.MAX_VALUE
    for (i in 1..n/2) {
        val j = n - i
        val sum = cal(i) + cal(j)
        if (sum < min) min = sum
    }

    println(min)
}

fun cal(num: Int): Int {
    var ans = 0
    var tmp = num
    while(tmp > 0) {
        ans += tmp % 10
        tmp /= 10
    }
    return ans
}