{-# OPTIONS_GHC -O #-}

import Data.Char
import Control.Monad
import Data.List

main = do
    n <- readLn :: IO Int
    print$ minimum $ map (mk n) [1..(n-1)]
    where
        mk n a = sum $ map digitToInt $ (show a ++ show (n-a))
