module Main where
import Data.List

int = read::String -> Int
main = interact $ printer . solver . parser

printer = unlines . (:[]) . show
parser = int

solver :: Int -> Int
solver k = minimum $ take 100000 $ map target [k,(k*2)..]

target 0 = 0 
target n = r + target q
  where
    (q,r) = divMod n 10
