"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    
    let list = [];
    
    for(let i=1; i<Math.floor(N / 2); i++) {
        if(N % i === 0) {
            list.push((i + (N / i)) - 2);
        }
    }

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