getDecimalSum :: Integer -> Integer
getDecimalSum x = sum $ map (read. (:[])) $ show x


main :: IO ()
main = do
  n <- read <$> getLine :: IO Integer
  print $ minimum [ getDecimalSum a + getDecimalSum b | a<-[1..n`div`2], let b = n-a]
