-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU

main = getLine
   >>= print
     . (\xs ->
           let len = length xs
           in if len < 2
               then read xs
               else 9 * len
       )