program main implicit none integer*8::N,i,j,k,M integer*8::min_d,num,num2 read *,N min_d = N num = CEILING(EXP(LOG(DBLE(N))/3.0_8)) do i=num, 1, -1 if(MOD(N,i).ne.0) cycle M = N/i num2 = CEILING(SQRT(DBLE(M))) do j=num2,1,-1 if(MOD(M,j).ne.0) cycle k = M/j min_d = MIN(min_d,i+j+k) end do end do print *,min_d-3 end program main