import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  val list = for {
    a <- 1 to N - 1
    b = N - a
  } yield a.toString.toList.map(_.asDigit).sum + b.toString.toList.map(_.asDigit).sum
  println(list.min)
}
