program main
  implicit none
  
  integer(16) :: i,j,n,m,l,p,q
  
  read(*,*)n
  m = int(sqrt(real(n)))
  do i = 1, m
    l = n/m
    if (m*l == n) then
      p = m
      q = l
    end if
  end do
  write(*,'(i0)')p+q-2
end program main