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 Rust (1.42.0) (judge verdict: Accepted)

#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use proconio::{marker::*, *};
#[fastout]
fn main() {
    input! {
        n:i64,
    }
    let mut ans = 99999999i64;
    for a in 1..n {
        let b = n - a;
        ans.chmin(digsum(b) + digsum(a));
    }
    println!("{}", ans);
}
trait ChMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}
impl<T: PartialOrd> ChMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
fn digsum(x: i64) -> i64 {
    let mut x = x;
    let mut ret = 0;
    while x > 0 {
        ret += x % 10;
        x /= 10;
    }
    ret
}