(* O(√n) *)
let n = read_int () in
let f a b =
  let rec f acc n = if n = 0 then acc else f (acc + 1) @@ n / 10 in
  f 0 @@ max a b in
let m = int_of_float @@ sqrt @@ float n in
for i = 1 to m do
  let j = m - i + 1 in
  if n mod j = 0 then (f j @@ n / j |> Printf.printf "%d\n"; exit 0)
done