main :: IO ()
main = do
  n <- readLn
  print $ g n

f :: Int -> [(Int,Int)]
f n = [(x, n-x) | x <- [1..((n+1) `div` 2)]]

sod
  :: Int -> Int
sod n
  | n `elem` [10^p | p <- [1..5]] = 10 -- 100 = 50+50 case 
  | otherwise = sum $ sod' n

sod' 
  :: Int -> [Int]
sod' n
  | q == 0 = [r] 
  | otherwise = r : sod' q
  where
    (q,r) = quotRem n 10

sod2 :: Int -> Int -> Int
sod2 x y = sod x + sod y

g :: Int -> Int
g = minimum . map (uncurry sod2) . f