! 2019.10.27
!
      program answer
      implicit none
      integer(8) :: N
      integer(8) :: ans
      real :: ru_N
      integer(8) :: S
      integer(8) :: T
      intrinsic dble,sqrt,mod
      read(*,*) N
!
      ru_N = sqrt(dble(N))
      S = ru_N-1
      do 
        if(mod(N,S) == 0) then
          T=N/S
          exit
        end if
        S = S-1
      end do
!
      write(*,*) T+S-2
      end program answer
