object Main extends App {
	val n = scala.io.StdIn.readInt
	
	var ans = 9999999

	for(x <- 1 until n){
		ans = math.min(ans, test(x)+test(n-x))
	}

	println(ans)

	def test(x: Int): Int = {
		var re = 0
		re += x/100000
		re += (x%100000)/10000
		re += (x%10000)/1000
		re += (x%1000)/100
		re += (x%100)/10
		re += x%10
		return re
	}

}