import Control.Applicative
import Data.List (group, sort, delete, tails)

-- http://tsumuji.cocolog-nifty.com/tsumuji/2010/07/project-euler-h.html
-- より
{- 素数関連 -}

-- 素数列
-- http://d.hatena.ne.jp/notogawa/20110114/1295006865 を参考に
-- gcd の使い方が秀逸
primes :: Integral a => [a]
primes = map fromIntegral primes'
    where
      primes' = [2, 3, 5] ++ f 5 7 (drop 2 primes')
      f m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
          where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]

-- 素数判定 --
isPrime :: Integral a => a -> Bool
isPrime n = (n > 1) && isPrime' primes
    where
      isPrime' (x : xs)
          | x * x > n    = True
          | rem n x == 0 = False
          | otherwise    = isPrime' xs

{- 素因数分解関連 -}

-- 素因数分解
factorize :: Integral a => a -> [(a, Int)]
factorize 1 = [(1, 0)]
factorize n = format $ factorize' n primes
    where
      format ps = [(x, length xs) | xs@(x : _) <- group ps]
      factorize' n ps@(p : ps')
          | p * p > n    = [n]
          | rem n p == 0 = p : factorize' (div n p) ps
          | otherwise    = factorize' n ps'

-- 約数
divisor :: Integral a => a -> [a]
divisor n = sort $ foldr distribute [1] ns
    where
      ns = [map (f^) [0 .. i] | (f, i) <- factorize n]
      distribute ns1 ns2 = [x * y | x <- ns1, y <- ns2]
      
digits :: Int -> Int
digits = length . show

f :: Int -> Int -> Int
f a b =
  if a < b
    then digits b
    else digits a

searcher :: Int -> [Int] -> Int
searcher n numList = minimum [f x (n `div` x) | x <- numList]

main = do
  n <- readLn
  let numList = divisor n 
  print $ searcher n numList