'use strict'
function main(input) {
  input = Number(input.trim())
  const sum = n => n.split('').reduce((p, c) => Number(p) + Number(c), 0)
  let ans = 0
  for (let i = 2; i < input - 1; i++) {
    let j = input - i
    let c = sum(String(i)+String(j))
    if (!ans || ans > c) ans = c
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
