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# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;


namespace practice1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a, b, min, buff;

            min = (int)(MYCP.SumKeta_Int(1, 10) + MYCP.SumKeta_Int(n - 1, 10));

            for (a = 1; a < n; a++)
            {
                b = n - a;
                buff = (int)(MYCP.SumKeta_Int(a, 10) + MYCP.SumKeta_Int(b, 10));
                if (buff < min) min = buff;
            }

            MYCP.Print_Int(min);
            return;
        }

        

    }

    

    class MYCP
    {
        //int変数を標準出力する
        public static void Print_Int(long number)
        {
            Console.WriteLine("" + number);
        }

        //int変数の配列を標準出力する
        public static void Print_Ints(int[] a)
        {
            if (a.Length == 0) return;

            Console.Write(a[0]);

            for(int i = 1; i < a.Length; i++)
            {
                Console.Write(" ");
                Console.Write(a[i]);
            }

            Console.WriteLine();
        }


        //文字列を配列化して返す
        public static string[] MyReadLineSplit()
        {
            return Console.ReadLine().Split();
        }

        //指定された個数分int変数を読み取る
        public static int[] Read_Ints(long number)
        {
            int[] a = new int[number];
            string[] buff = MyReadLineSplit();
            for (long i = 0; i < number; i++)
            {
                a[i] = int.Parse(buff[i]);
            }

            return a;
        }

        //指定された個数分BigInteger変数を読み取る
        public static BigInteger[] Read_BigIntegers(long number)
        {
            BigInteger[] a = new BigInteger[number];
            string[] buff = MyReadLineSplit();
            for(long i = 0; i < number; i++)
            {
                a[i] = BigInteger.Parse(buff[i]);
            }

            return a;
        }



        //渡された自然数が素数か判定する。素数ならtrueを返す。
        public static bool PrimeCheck_Int(int number)
        {
            if (number < 2) return false;

            for(int i = 2; i < number; i++)
            {
                if (number % i == 0) return false;
            }

            return true;
        }

        //渡された自然数が累乗数か判定する。累乗数ならtrueを返す。
        public static bool Bekizyousuu_Check_Int(int number)
        {
            if (number == 1) return true;

            int i, copy;


            for (i = 2; i < number; i++)
            {
                copy = number;
                while (copy % i == 0)
                {
                    copy /= i;
                }

                if (copy == 1) return true;
            }

            return false;
        }

        //BIgIntegerで累乗計算を行う
        public static BigInteger MyPower_BigInteger(BigInteger a,BigInteger b)
        {
            BigInteger i, x = 1;

            for (i = 0; i < b; i++)
            {
                x *= a;
            }

            return x;
        }

        //渡されたBigIntegerの配列の和を求める
        public static BigInteger MySum_BigInteger(BigInteger[] a)
        {
            BigInteger sum = 0;
            int i;

            for (i = 0; i < a.Length; i++)
            {
                sum += a[i];
            }

            return sum;

        }

        public static int SumKeta_Int(int a,int N_shinhou)
        {
            if (a <= 0) return 0;
            int sum = 0;

            while (a > 0)
            {
                sum += a % N_shinhou;
                a -= a % N_shinhou;
                a /= N_shinhou;

            }

            return sum;

        }
    }
}