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 C (Clang 3.8.0) (judge verdict: Accepted)

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

static uint32_t calcDigitSum(const uint32_t A, const uint32_t B) {
	uint32_t sum = 0;
	uint32_t dividedA = A;
	uint32_t dividedB = B;

	while (dividedA > 0) {
		sum += dividedA % 10;
		dividedA /= 10;
	}
	while (dividedB > 0) {
		sum += dividedB % 10;
		dividedB /= 10;
	}

	return sum;
}

int main(void) {
	uint32_t N;
	uint32_t min = UINT32_MAX;

	scanf("%"PRIu32, &N);

	for (uint32_t A = 1; A < N; A++) {
		const uint32_t B = N - A;
		const uint32_t digitSum = calcDigitSum(A, B);
		if (digitSum < min) {
			min = digitSum;
		}
	}

	printf("%"PRIu32, min);

	return 0;
}