
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        double target = scanner.nextDouble();
    //    long start = System.currentTimeMillis(); 
        long ans = calc(target);
    //    long end = System.currentTimeMillis(); 
    //    long time = end - start;
        System.out.println(ans );
    //    System.out.println(time +"ms");
    }
    
    /**
     * @param target
     * @return
     */
    public static  long calc(double target){
        long targetNum = (long)target;
        long root = 0;
        long divNum = 0;
        long ansNum = 0;
        long sumNum = 0;
        root = (long) Math.sqrt(target);
        for (long i = root; i > 0; i--) 
        {
            if (targetNum % i == 0 ) {
                divNum = i;
                break;
            }
        }
        ansNum = targetNum / divNum;
        sumNum = ansNum + divNum -2;
        return sumNum;
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz