"use strict";

const divisor = num => {
    let results = [];
    
    for(let i=1; i<=num; i++) {
        if( (num % i === 0) ) {
            results.push(i);
        }
    }
    
    return results;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    
    const divisions = divisor(N);
    
    let answers = [];

    for(let i in divisions) {
        let temp = parseInt(divisions[i]) + (N / divisions[i]) - 2;

        answers.push(temp);
    }
    
    
    console.log(Math.min(...answers));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
