import Data.Char
import Data.List
main::IO()
main = do
    n <- readLn :: IO Double
    let r =  (floor . fromRational . toRational . sqrt) n
        m = truncate n
        ans = if (isP . fromIntegral) m then digitLen m
                                        else digitLen $ solve m r

    print $ ans


solve::Integer -> Integer-> Integer 
solve m r = case find (\x -> m `mod` x == 0) [r,(r + 1)..m] of
                 Just x -> x
                 Nothing -> 0

digitLen::Integer-> Int
digitLen = (length . map digitToInt . show)

isP::Int->Bool
isP n 
    |n < 2 = False
    |n == 2 = True
    |n `mod` 2 == 0 = False
    |otherwise = try n 3
    where
        try :: Int->Int->Bool
        try m i
            |i*i > m=True
            |m `mod` i == 0 = False
            |otherwise = try m (i+2)
