"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);
    const center = divisions[Math.ceil(divisions.length / 2)];
    
    // let answers = [];
    
    // console.log(divisions)

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

    //     answers.push(temp);
    // }
    
    let answer =  center + (N / center) - 2;
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
