import Control.Applicative
import Control.Monad
import qualified Data.List
import qualified Data.Char as C
import Debug.Trace

main ::IO()
main = do
  n <- read <$> getLine -- :: IO Int
  putStrLn $ show $ solve n 

solve :: Int -> Int 
solve n =
  ans
  where
    m = ceiling $ fromIntegral n / 10
    n' = n-m
    cand1 =digs m+ digs n'
    cand2 = digs n
    ans = maximum [cand1,cand2]

-- -- functions --

digs :: Integral x => x -> x
digs 0 = 0
digs x = x `mod` 10 + digs (x `div` 10)
