
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		long startTime = System.currentTimeMillis();
		Scanner sc = new Scanner(System.in) ;
		long thing = sc.nextLong();
		//System.out.println(thing*thing+thing+thing);
		//System.out.println(Integer.MAX_VALUE);
		long i = thing;
		long j = thing;
		for (long ii = 1 ; ii <= Math.pow(thing, 0.5) ; ii ++ ) {
			if (thing % ii != 0) { continue;}
			if ((ii+(thing/ii)) < i+j) {
				i=ii;j=(thing/ii);
			}
			//System.out.println(thing/ii+" "+ii);
		}
		//System.out.println(System.currentTimeMillis()-startTime);
		System.out.println(i+ j-2);
		
	}
}

/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