object Main {
  def main(args: Array[String]) {
    val sum = io.StdIn.readLine.toInt
    val candidates = for (j <- (1 until sum)) yield (j, sum - j)
    println(candidates.map(t => sumOfEachRank(t._1) + sumOfEachRank(t._2)).min)
  }

  def sumOfEachRank(n: Int): Int =
    n.toString.map(_.asDigit).sum
}
