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(1, 10) + MYCP.SumKeta(n - 1, 10));

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

            MYCP.PrintNumber(min);
            return;
        }

        

    }

    

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

        //int変数の配列を標準出力する
        public static void PrintNumbers(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();
        }


        //double変数をソートする
        public static void MyDoubleSort(double[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            double a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        //int変数をソートする
        public static void MyIntSort(int[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            int a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        //指定された個数分int変数を読み取る
        public static int[] ReadNumbers(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[] ReadBigIntegers(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 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 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 MyPowerBigInteger(BigInteger a,BigInteger b)
        {
            BigInteger i, x = 1;

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

            return x;
        }

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

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

            return sum;

        }

        public static BigInteger SumKeta(BigInteger a,BigInteger N_shinhou)
        {
            if (a <= 0) return 0;
            BigInteger sum = 0;

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

            }

            return sum;

        }
    }
}

Measured memory_bytes: 13268