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 = sum . sod'
sod' n
  | q == 0 = [r] 
  | otherwise = r : sod' q
  where
    (q,r) = quotRem n 10

g = minimum . map (\(x,y) -> (sod x) + (sod y)) . f