fun main(args: Array<String>) {

    val N = readInts()[0]

    var min = Long.MAX_VALUE
    for(i in 1 until N) {
        val t = sum(i) + sum(N - i)
        if (t <= min) {
            min = t
        }
    }

    println(min)
}

fun sum(i: Int): Long = i.toString().map { it.toString().toInt() }.sum().toLong()

fun readInts(): List<Int> = readStrings().map { it.toInt() }
fun readStrings(): List<String> = readLine()!!.split(" ")