integer,parameter :: p = 8
integer(p) :: n

do i = ceiling(sqrt(real(n))),1,-1
  if( mod(n,i)==0 ) exit
end do

print*,max(digit(i),digit(n/i))

contains
function digit( n ) result( i )
  i = 0
  do while( n/=0 )
    n = n / 10
    i = i + 1
  end do
end function
    

end
