function Main(input){
  var N = Number(input);
  var m = N*N;
  for(var i=1;i<N;i++){
    var is = String(i);
    var iNs = String(N-i);
    var tmp = 0;
    for(var j of is){
      tmp+=Number(j);
    }
    for(var j of iNs){
      tmp+=Number(j);
    }
    if(tmp<m){
      m=tmp;
    }
  }
  console.log(m);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));