program problemC
  implicit none

  integer, parameter    :: i8 = selected_int_kind  ( 18 )
  integer ( kind = i8 ) :: N, i, ans, tmp

  read *, N

  ans = N

  do i = 1, int ( sqrt ( real ( N ) ) )
!     print *, i
     if ( mod ( N, i ) == 0 ) then
        tmp = N / i + i - 2
        if ( tmp < ans ) then
           ans = tmp
        end if
     end if
  end do

  print *, ans
  
end program problemC

     
