function Main(input) {
    input.trim().split("\n").forEach(line => {
        var a = parseInt(line);
        var root = Math.floor(Math.sqrt(a));
        for (var i = root; i > 0; i--) {
            if (a % i === 0) {
                console.log(i + (a / i) - 2);
                return;
            }
        }
    });
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
var globalInput = '';
process.stdin.on('data', function(chunk) {
    globalInput += chunk;
})
process.stdin.on('end', function() {
    Main(globalInput)
})

// Main(require("fs").readFileSync("/dev/stdin", "utf8"));