Problem:
Score : 200 points

Problem Statement

Takahashi has two positive integers A and B.

It is known that A plus B equals N.
Find the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B" (in base 10).

Constraints

2 ≤ N ≤ 10^5

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the minimum possible value of "the sum of the digits of A" plus "the sum of the digits of B".

Sample Input 1

15

Sample Output 1

6

When A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.

Sample Input 2

100000

Sample Output 2

10

Solution in PHP (5.6.30) (judge verdict: Accepted)

<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B,$C,$D) = explode(" ",trim(fgets(STDIN)));
//$A  = explode(" ",trim(fgets(STDIN)));

preg_match_all("([0-9])", $N, $m);
$res = array_sum($m[0]);
if ($res == 1) {
  $res = 10;
}
printf("%d\n",$res);
exit;
$wa = 99999999999;
for($i=1;$i<$N/2;$i++) {
  $wa = min($wa,getWa($i,$N-$i));
}
printf("%d\n",$wa);

function getWa($n1,$n2) {
  $sum = 0;
  preg_match_all("([0-9])", $n1, $m);
  $sum += array_sum($m[0]);
  preg_match_all("([0-9])", $n2, $m);
  $sum += array_sum($m[0]);
  printf("%d %d %d\n",$n1,$n2,$sum);
  return $sum;
}