import Text.Printf
import Data.Char

main :: IO()
main = do
  [n] <- map read . words <$> getLine
  printf "%d" $ minimum $ map (\(x, y) -> convVal x + convVal y) [(x, n - x) | x <- [1 .. (n - 1)]]

convVal :: Int -> Int
convVal n = sum nList
  where nList = map digitToInt $ show n
