let digit = string >> Seq.length >> int64
let max64 (a: int64) (b: int64) = if a <= b then b else a
let min64 (a: int64) (b: int64) = if a <= b then a else b

let rec maxDivisorDigit n a acc =
    let aPlus =
        match a with
        | 1L -> 2L
        | 2L -> 3L
        | _ -> a + 2L

    if n < a * a then acc
    elif n % a = 0L then maxDivisorDigit n aPlus (max64 (digit a) (digit n / a))
    else maxDivisorDigit n aPlus acc

//let inputs = [| 10000L; 1000003L; 9876543210L |]
//let n = inputs.[0]
//maxDivisorDigit n 1L 0L

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int64
    maxDivisorDigit n 1L 0L |> printfn "%d"
    0
