      PROGRAM walkOnMulti
      IMPLICIT NONE
      INTEGER(8) :: N
      INTEGER(8) :: rt,i,ans,bigger,smaller
      
      
      
      READ *,N
      
      rt = aint(sqrt( real(N) )) + 1
      
      DO i = rt,N
        IF( mod(N,i)==0 )THEN
          bigger = i
          smaller = N / bigger
          EXIT
        END IF
      END DO
      
      ans = (bigger-1) + (smaller-1)
      
      print*,ans
      
      
      
      
      END PROGRAM