object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val n = readLine.split(" ").map(_.toInt).head

    val ans = (1 until n).map(a => (a.toString + (n - a).toString).split("").filterNot(_ == "").map(_.toInt).sum).min

    println(ans)
  }
}
