a = gets.chomp.to_i

MAX = 10**12

def solve(a)
    i = 1

    minStep = MAX

    while i <= Math.sqrt(a)
        if a % i == 0
            j = a / i
            step = (i-1) + (j-1)
            minStep = [minStep, step].min
        end
        i += 1
    end

    return minStep
end

puts solve(a)