let input_line = readLine()!.characters.split{$0==" "}.map { Int(String($0))! }
let n = input_line[0]
let minSum = (1...n).filter { n % $0 == 0 }.map { Int($0 + (n / $0)) }.minElement()!
print(minSum - 2)