      PROGRAM WalkOnMultiplicationTable
      IMPLICIT NONE
      integer(16) :: n,sqrtN,i,j
      
      read*,n
      
      sqrtN = ceiling(sqrt(real(N)))
      !print*,sqrtN
      
      !find i
      i = sqrtN
      do while( .true. )
        if( mod(n,i)==0 ) exit
        i = i - 1
      end do
      j = n / i
      
      print*,(j-1) + (i-1)
      
      
      
      END PROGRAM