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 =
    if n <= a * a then
        // n = 1 のエッジケースへの対処
        if n = 1L then 1L else acc
    elif n % a = 0L then
        let newDigit = (max64 (digit a) (digit (n / a)))
        maxDivisorDigit n (a + 1L) (min64 acc newDigit)
    else
        maxDivisorDigit n (a + 1L) acc

//for n in [| 1L; 2L; 10000L; 1000003L; 9876543210L |] do maxDivisorDigit n 1L n |> printfn "%i"

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