import Control.Applicative
import Data.List

main = do
    n <- readLn
    print $ solve n

solve :: Int -> Int
solve n = minimum $ map (f n) [1..(1 + div n 2)]

f :: Int -> Int -> Int
f n a = g (show a) + g (show b)
    where b = n - a

g :: String -> Int
g digStr = sum $ map (read . (\chr->[chr])) digStr