"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    
    let answer = N - 1;
    
    for(let i=2; i<N; i++) {
        if(N % i === 0 && (N / i) <= i) {
            answer = (i - 1) + ((N / i) - 1);
            break;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));