import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val n = input.nextLine().toInt

      output.println {
        1.until(n).map { i =>
          val a = i
          val b = n - i
          (a.toString + b.toString).split("").filter(_ != "").map(_.toInt).sum
        }.min
      }
    }

  }

}
