import Control.Applicative
import Control.Monad
import Data.List

dsum :: Int -> Int
dsum n
    | q == 0    = r
    | otherwise = r + dsum q
  where
    (q, r) = n `divMod` 10

main :: IO ()
main = do
    n <- readLn :: IO Int
    let as = do
            a <- [1 .. n `div` 2]
            let b = n - a
            return $ dsum a + dsum b
    print $ minimum as