
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		/*
		 * Scannerで値取得。
		 */
		Scanner snum = new Scanner(System.in);

		//値取得
		long numN = snum.nextLong();

		snum.close();

		long tate = 0;
		long yoko = 0;

		//		numNを割る
		long halfLong = (long) (Math.sqrt(numN));

		//		halfLongの値から1ずつデクリメントしながら割り切れる値を探す
		//		割り切れたら割る→縦横の和から２引く
		for (tate = halfLong; tate > 0; tate--) {
			if (numN % tate == 0) {
				yoko = numN / tate;
				System.out.println(tate + yoko - 2);
				break;
			}
		}
	}

}

/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