main = do
  n <- readLn :: IO Integer
  print $ minimum [maximum [f a,f b] | a<-[1..sq n], let b = div n a, a*b==n]
  where
    f 0 = 0
    f x = 1 + (f (div x 10))
    sq = truncate . sqrt . fromIntegral
