program A320B
    implicit none
    integer(8)::N,ans,i,Ns
    read*,N
    Ns=int(sqrt(real(N)))+1
    ans=N
    do i=1,Ns
        if(mod(N,i)==0)ans=min(ans,i+N/i-2)
    end do

    print'(i0)',ans
end program A320B