//繰り返し二乗法 repow(b,p)(b,p,modder)
//ユークリッド互除法で最大公約数 gcd
//gcdで最小公倍数 lcm
//約数列挙divList(int)
//約数列挙divSet(int)
//素数判定iP(long)とtameshiwari(long)
//BSA()()()(List<T>,T,int,int,Comparator<T>)
//BSF()()()(List<T>,T,int,int,Comparator<T>)
//BSL()()()(List<T>,T,int,int,Comparator<T>)
//BSA()()()(T[],T,int,int,Comparator<T>)
//BSF()()()(T[],T,int,int,Comparator<T>)
//BSL()()()(T[],T,int,int,Comparator<T>)
//BSA()()()(int[],int,int,int,syojun)
//BSF()()()(int[],int,int,int,syojun)
//BSL()()()(int[],int,int,int,syojun)
//int kmp(String t,String p)
//文字列文字ソートStSort(String)
//二次元整数座標オブジェクトXy
////マンハッタン距離manht(Xy)
////toString
////偏角ソート用hencom
////偏角henkaku
////equals
//ユニオンファインドUnFd
////boolean isRoot(i)
////int rootOf(i)
////boolean ud(i,j)
////boolean marge(i,j)
////int[] roots()
//スキャナーScnr
////next nextBuilder nextInt nextLong nextDouble()
////nextAInt nextALong nextADouble(n)(a[],n)(a[],off,len)
////nextLInt nextLLong nextLDouble(n)
//static PrintWriter out = new PrintWriter(System.out);
import java.util.*;
import java.io.*;

class Main{
  static int repow(int b,int p){
    long a = b;
    long res=1;
    while(p>0){
      if(p%2==1){
        res*=a;
      }
      a*=a;
      p/=2;
    }
    return (int)res;
  }
  static int repow(int b,int p,int modder){
    long a = b%modder;
    long res=1;
    while(p>0){
      if(p%2==1){
        res=(res*a)%modder;
      }
      a=(a*a)%modder;
      p/=2;
    }
    return (int)res;
  }
  static long repow(long b,long p){
    long a = b;
    long res=1;
    while(p>0){
      if(p%2==1){
        res*=a;
      }
      a*=a;
      p/=2;
    }
    return res;
  }
  static long repow(long b,long p,long modder){
    long a = b%modder;
    long res=1;
    while(p>0){
      if(p%2==1){
        res=(res*a)%modder;
      }
      a=(a*a)%modder;
      p/=2;
    }
    return res;
  }
  static long gcd(long c,long d){
    while(true){
      long f=c%d;
      if(f==0){
        return d;
      }
      c=d;
      d=f;
    }
  }
  static long lcm(long c,long d){
    return c/gcd(c,d)*d;
  }
  static ArrayList<Integer> divList(int n){
    ArrayList<Integer> div=new ArrayList<Integer>();
    for(int i=1;i*i<=n;i++){
      if(n%i==0){
        div.add(i);
        if(i*i!=n){
          div.add((int)(n/i));
        }
      }
    }
    return div;
  }
  static HashSet<Integer> divSet(int n){
    HashSet<Integer> div=new HashSet<Integer>();
    for(int i=1;i*i<=n;i++){
      if(n%i==0){
        div.add(i);
        div.add((int)(n/i));
      }
    }
    return div;
  }
  static boolean iP(long n){
    if(n==2){
      return true;
    }
    if((n&1)==0||n==1){
      return false;
    }
//    if(n>3037007383L){
    if(n>Integer.MAX_VALUE){
      return tameshiwari(n);
    }
    long d=n-1;
    int s=0;
    while((d&1)==0){
      d/=2;
      s++;
    }
    int[] aa = {2,3,5,7,11,13,17};
    for(int i=0;i<7&&aa[i]<n;i++){
      int a = aa[i];
      long t = d;
      long y=repow(a,t,n);
      while(t!=n-1&&y!=1&&y!=n-1){
        y = (y*y)%n;
        t=t<<1;
      }
      if(y!=n-1&&(t&1)==0){
        return false;
      }
    }
    return true;
  }
  static boolean tameshiwari(long n){
    for(long i=2;i*i<=n;i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
  static <T extends Comparable<T>> int BSA(List<T> l,T target){
    return BSA(l,target,0,l.size(),(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSA(List<T> l,T target,Comparator<T> c){
    return BSA(l,target,0,l.size(),c);
  }
  static <T extends Comparable<T>> int BSA(List<T> l,T target,int left,int right){
    return BSA(l,target,left,right,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSA(List<T> l,T target,int left,int right,Comparator<T> c){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      T gaze=l.get(lt+(rt-lt)/2);
      if(c.compare(gaze,target)<0){
        lt=lt+(rt-lt)/2+1;
      }else if(c.compare(gaze,target)>0){
        rt=lt+(rt-lt)/2-1;
      }else{
        return lt+(rt-lt)/2;
      }
    }
    return -1;
  }
  static <T extends Comparable<T>> int BSF(List<T> l,T target){
    return BSF(l,target,0,l.size(),(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSF(List<T> l,T target,Comparator<T> c){
    return BSF(l,target,0,l.size(),c);
  }
  static <T extends Comparable<T>> int BSF(List<T> l,T target,int left,int right){
    return BSF(l,target,left,right,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSF(List<T> l,T target,int left,int right,Comparator<T> c){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      T gaze=l.get(lt+(rt-lt)/2);
      if(c.compare(gaze,target)<0){
        lt=lt+(rt-lt)/2+1;
      }else if(c.compare(gaze,target)>=0){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static <T extends Comparable<T>> int BSL(List<T> l,T target){
    return BSL(l,target,0,l.size(),(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSL(List<T> l,T target,Comparator<T> c){
    return BSL(l,target,0,l.size(),c);
  }
  static <T extends Comparable<T>> int BSL(List<T> l,T target,int left,int right){
    return BSL(l,target,left,right,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSL(List<T> l,T target,int left,int right,Comparator<T> c){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      T gaze=l.get(lt+(rt-lt)/2);
      if(c.compare(gaze,target)<=0){
        lt=lt+(rt-lt)/2+1;
      }else if(c.compare(gaze,target)>0){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static <T extends Comparable<T>> int BSA(T[] a,T target){
    return BSA(a,target,0,a.length,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSA(T[] a,T target,Comparator<T> c){
    return BSA(a,target,0,a.length,c);
  }
  static <T extends Comparable<T>> int BSA(T[] a,T target,int left,int right){
    return BSA(a,target,left,right,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSA(T[] a,T target,int left,int right,Comparator<T> c){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      T gaze=a[lt+(rt-lt)/2];
      if(c.compare(gaze,target)<0){
        lt=lt+(rt-lt)/2+1;
      }else if(c.compare(gaze,target)>0){
        rt=lt+(rt-lt)/2-1;
      }else{
        return lt+(rt-lt)/2;
      }
    }
    return -1;
  }
  static <T extends Comparable<T>> int BSF(T[] a,T target){
    return BSF(a,target,0,a.length,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSF(T[] a,T target,Comparator<T> c){
    return BSF(a,target,0,a.length,c);
  }
  static <T extends Comparable<T>> int BSF(T[] a,T target,int left,int right){
    return BSF(a,target,left,right,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSF(T[] a,T target,int left,int right,Comparator<T> c){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      T gaze=a[lt+(rt-lt)/2];
      if(c.compare(gaze,target)<0){
        lt=lt+(rt-lt)/2+1;
      }else if(c.compare(gaze,target)>=0){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static <T extends Comparable<T>> int BSL(T[] a,T target){
    return BSL(a,target,0,a.length,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSL(T[] a,T target,Comparator<T> c){
    return BSL(a,target,0,a.length,c);
  }
  static <T extends Comparable<T>> int BSL(T[] a,T target,int left,int right){
    return BSL(a,target,left,right,(s1,s2)->s1.compareTo(s2));
  }
  static <T> int BSL(T[] a,T target,int left,int right,Comparator<T> c){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      T gaze=a[lt+(rt-lt)/2];
      if(c.compare(gaze,target)<=0){
        lt=lt+(rt-lt)/2+1;
      }else if(c.compare(gaze,target)>0){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static int BSA(int[] a,int target){
    return BSA(a,target,0,a.length,true);
  }
  static int BSA(int[] a,int target, boolean syojun){
    return BSA(a,target,0,a.length,syojun);
  }
  static int BSA(int[] a,int target,int left,int right){
    return BSA(a,target,left,right,true);
  }
  static int BSA(int[] a,int target,int left,int right,boolean syojun){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      int gaze=a[lt+(rt-lt)/2];
      if((syojun&&gaze<target)||(!syojun&&gaze>target)){
        lt=lt+(rt-lt)/2+1;
      }else if((syojun&&gaze>target)||(!syojun&&gaze<target)){
        rt=lt+(rt-lt)/2-1;
      }else{
        return lt+(rt-lt)/2;
      }
    }
    return -1;
  }
  static int BSF(int[] a,int target){
    return BSF(a,target,0,a.length,true);
  }
  static int BSF(int[] a,int target,boolean syojun){
    return BSF(a,target,0,a.length,syojun);
  }
  static int BSF(int[] a,int target,int left,int right){
    return BSF(a,target,left,right,true);
  }
  static int BSF(int[] a,int target,int left,int right,boolean syojun){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      int gaze=a[lt+(rt-lt)/2];
      if((syojun&&gaze<target)||(!syojun&&gaze>target)){
        lt=lt+(rt-lt)/2+1;
      }else if((syojun&&gaze<=target)||(!syojun&&gaze>=target)){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static int BSL(int[] a,int target){
    return BSL(a,target,0,a.length,true);
  }
  static int BSL(int[] a,int target,boolean syojun){
    return BSL(a,target,0,a.length,syojun);
  }
  static int BSL(int[] a,int target,int left,int right){
    return BSL(a,target,left,right,true);
  }
  static int BSL(int[] a,int target,int left,int right,boolean syojun){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      int gaze=a[lt+(rt-lt)/2];
      if((syojun&&gaze<=target)||(!syojun&&gaze>=target)){
        lt=lt+(rt-lt)/2+1;
      }else if((syojun&&gaze>target)||(!syojun&&gaze<target)){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static int BSA(long[] a,long target){
    return BSA(a,target,0,a.length,true);
  }
  static int BSA(long[] a,long target, boolean syojun){
    return BSA(a,target,0,a.length,syojun);
  }
  static int BSA(long[] a,long target,int left,int right){
    return BSA(a,target,left,right,true);
  }
  static int BSA(long[] a,long target,int left,int right,boolean syojun){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      long gaze=a[lt+(rt-lt)/2];
      if((syojun&&gaze<target)||(!syojun&&gaze>target)){
        lt=lt+(rt-lt)/2+1;
      }else if((syojun&&gaze>target)||(!syojun&&gaze<target)){
        rt=lt+(rt-lt)/2-1;
      }else{
        return lt+(rt-lt)/2;
      }
    }
    return -1;
  }
  static int BSF(long[] a,long target){
    return BSF(a,target,0,a.length,true);
  }
  static int BSF(long[] a,long target,boolean syojun){
    return BSF(a,target,0,a.length,syojun);
  }
  static int BSF(long[] a,long target,int left,int right){
    return BSF(a,target,left,right,true);
  }
  static int BSF(long[] a,long target,int left,int right,boolean syojun){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      long gaze=a[lt+(rt-lt)/2];
      if((syojun&&gaze<target)||(!syojun&&gaze>target)){
        lt=lt+(rt-lt)/2+1;
      }else if((syojun&&gaze<=target)||(!syojun&&gaze>=target)){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static int BSL(long[] a,long target){
    return BSL(a,target,0,a.length,true);
  }
  static int BSL(long[] a,long target,boolean syojun){
    return BSL(a,target,0,a.length,syojun);
  }
  static int BSL(long[] a,long target,int left,int right){
    return BSL(a,target,left,right,true);
  }
  static int BSL(long[] a,long target,int left,int right,boolean syojun){
    int lt = left;
    int rt = right-1;
    while(lt<=rt){
      long gaze=a[lt+(rt-lt)/2];
      if((syojun&&gaze<=target)||(!syojun&&gaze>=target)){
        lt=lt+(rt-lt)/2+1;
      }else if((syojun&&gaze>target)||(!syojun&&gaze<target)){
        rt=lt+(rt-lt)/2-1;
      }
    }
    return lt;
  }
  static int kmp(String t,String p){
    int[] f=new int[p.length()+1];
    int i=0;
    int j=1;
    f[1]=0;
    while(j<p.length()){
      if(i==0||p.charAt(i-1)==p.charAt(j-1)){
        i++;
        j++;
        f[j]=i;
      }else{
        i=f[i];
      }
    }
    i=1;
    j=1;
    while(i<=p.length()&&j<=t.length()){
      if(i==0||p.charAt(i-1)==t.charAt(j-1)){
        i++;
        j++;
      }else{
        i=f[i];
      }
    }
    return i==(p.length()+1)?j-i:-1;
  }
  static String StSort(String s){
    StringBuilder sb = new StringBuilder(s);
    int lg = sb.length();
    int l;
    int r;
    int gaze;
    for(int i=1;i<lg;i++){
      l=0;
      r=i-1;
      while(l<=r){
        gaze=(l+r)/2;
        if(sb.charAt(gaze)<=sb.charAt(i)){
          l=gaze+1;
        }else if(sb.charAt(gaze)>sb.charAt(i)){
          r=gaze-1;
        }
      }
      sb.insert(l,sb.charAt(i));
      sb.deleteCharAt(i+1);
    }
    return sb.toString();
  }
  static class Xy{
    int x;
    int y;
    Xy(int x,int y){
      this.x=x;
      this.y=y;
    }
    public int manht(Xy o){
      return Math.abs(x-o.x)+Math.abs(y-o.y);
    }
    public String toString(){
      return "["+x+","+y+"]";
    }
    public double henkaku(){
      return Math.atan2(y,x);
    }
    public static int hencom(Xy s1,Xy s2){
      return (int)Math.signum(s1.henkaku()-s2.henkaku());
    }
    public boolean equals(Object o){
      return x==((Xy)o).x&&y==((Xy)o).y;
    }
  }
  static class UnFd{
    int n;
    int[] a;
    int forest;
    UnFd(int n){
      forest=this.n=n;
      a = new int[n];
      for(int i=0;i<n;i++){
        a[i] = i;
      }
    }
    boolean isRoot(int i){
      return a[i]==i;
    }
    int rootOf(int i){
      if(isRoot(i)){
        return i;
      }
      return a[i] = rootOf(a[i]);
    }
    boolean ud(int i,int j){
      return rootOf(i)==rootOf(j);
    }
    boolean marge(int i,int j){
      if(ud(i,j)){
        return false;
      }
      i=rootOf(i);
      j=rootOf(j);
      a[Integer.max(i,j)]=Integer.min(i,j);
      forest-=1;
      return true;
    }
    int[] roots(){
      int[] rs = new int[forest];
      int p=0;
      for(int i=0;i<n;i++){
        if(isRoot(i)){
          rs[p]=i;
          p++;
        }
      }
      return rs;
    }
  }
  static class Scnr{
    private final InputStream ins;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    Scnr(){
      this(System.in);
    }
    Scnr(InputStream in){
      ins = in;
    }
    private boolean hasNextByte(){
      if(ptr<buflen){
        return true;
      }else{
        ptr = 0;
        try{
          buflen = ins.read(buffer);
        }catch(IOException e){
          e.printStackTrace();
        }
        if(buflen<=0){
          return false;
        }
      }
      return true;
    }
    private int readByte(){
      if(hasNextByte()){
        return buffer[ptr++];
      }else{
        return -1;
      }
    }
    private static boolean isPrintableChar(int c){
      return 33<=c&&c<=126;
    }
    public boolean hasNext(){
      while(hasNextByte()&&!isPrintableChar(buffer[ptr])){
        ptr++;
      }
      return hasNextByte();
    }
    public String next(){
      return nextBuilder().toString();
    }
    public StringBuilder nextBuilder(){
      if(!hasNext()){
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)){
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb;
    }
    public double nextDouble(){
      return Double.parseDouble(next());
    }
    public long nextLong(){
      if(!hasNext()){
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if(b=='-'){
        minus=true;
        b=readByte();
      }
      if(b<'0'||'9'<b){
        throw new NumberFormatException();
      }
      while(true){
        if('0'<=b&&b<='9'){
          n*=10;
          n+=b-'0';
        }else if(b==-1||!isPrintableChar(b)){
          return minus?-n:n;
        }else{
          throw new NumberFormatException();
        }
        b=readByte();
      }
    }
    public int nextInt(){
      long nl=nextLong();
      if(nl<Integer.MIN_VALUE||Integer.MAX_VALUE<nl){
        throw new NumberFormatException();
      }
      return (int) nl;
    }
    public int[] nextAInt(int n){
      int[] a = new int[n];
      nextAInt(a,n);
      return a;
    }
    public void nextAInt(int[] a,int n){
      nextAInt(a,0,n);
    }
    public void nextAInt(int[] a,int off,int len){
      for(int i=off;i<off+len;i++){
        a[i] = nextInt();
      }
    }
    public long[] nextALong(int n){
      long[] a = new long[n];
      nextALong(a,n);
      return a;
    }
    public void nextALong(long[] a,int n){
      nextALong(a,0,n);
    }
    public void nextALong(long[] a,int off,int len){
      for(int i=off;i<off+len;i++){
        a[i] = nextLong();
      }
    }
    public double[] nextADouble(int n){
      double[] a = new double[n];
      nextADouble(a,n);
      return a;
    }
    public void nextADouble(double[] a,int n){
      nextADouble(a,0,n);
    }
    public void nextADouble(double[] a,int off,int len){
      for(int i=off;i<off+len;i++){
        a[i] = nextDouble();
      }
    }
    public List<Integer> nextLInt(int n){
      List<Integer> l = new ArrayList<>(n);
      for(int i=0;i<n;i++){
        l.add(sc.nextInt());
      }
      return l;
    }
    public List<Long> nextLLong(int n){
      List<Long> l = new ArrayList<>(n);
      for(int i=0;i<n;i++){
        l.add(sc.nextLong());
      }
      return l;
    }
    public List<Double> nextLDouble(int n){
      List<Double> l = new ArrayList<>(n);
      for(int i=0;i<n;i++){
        l.add(sc.nextDouble());
      }
      return l;
    }
  }

  static Scnr sc = new Scnr();
  static PrintWriter out = new PrintWriter(System.out);
  public static void main(String args[]){
//    int n=sc.nextInt();
    long a=sc.nextLong();
//    int b=sc.nextInt();
//    int c=sc.nextInt();

//    String s=sc.next();
//    String t=sc.next();
    long x=0;
    long y=0;
    for(long i=(long)Math.ceil(Math.sqrt(a));true;i--){
      if((a/i)*i==a){
        x=i;
        y=a/i;
        break;
      }
    }
    out.println(x+y-2);
//    out.println(x+" "+y);
    out.flush();
  }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long N = sc.nextLong();
		int sqrt = (int)Math.sqrt(N);
		int d = 0;
		for (int i = sqrt; i > 0; i--) {
			if (N % i == 0) {
				d = i;
				break;
			}
		}
		long ans = N / d + d - 2;
		System.out.println(ans);
	}

	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long res;

        long max=1;
        for(int i=1; i<Math.sqrt(N)+1; i++){
            if(N%i==0){

                max = i;

            }
        }
        res = max+N/max-2;
        System.out.println(res);
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n   = Long.parseLong(sc.nextLine());
		long ans = 0;

		for(int i = 1; i < Math.sqrt(n);i++) {

			if(n % i == 0) {

				ans = Math.max(ans, i);
			}

		}

		System.out.println(ans + n / ans - 2);
	}
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long tmp1 = 0;
        long tmp2 = 0;
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                tmp1 = i;
                if (i != n / i) {
                    tmp2 = n / i;
                }
                if(tmp2 <= tmp1) break;
            }
        }
        long ans = tmp2 + tmp1 -2;
        System.out.println(ans);
    }
}


#include <stdio.h>
#include <math.h>

int main()
{
	double N;
	scanf("%lf", &N);

	double i, j;
	for (i = floor(sqrt(N)); i >= 1; i--) {
		j = floor(N / i);
		if (i * j == N)  break;
	}
    printf("%.0lf", -2+i+j);
	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	ll N;
	scanf("%lld", &N);

	int sq = sqrt(N);
	ll saishou = 1e18;
	for (int i = sq; i >= 1; i--) {
		if ((ll)((double)N / i) * i == N) {
			printf("%lld", N / i + i - 2);
			return 0;
		}
	}

	Would you please return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int n;
    while(cin>>n)
    {
        long long int x=sqrt((double)n);
        double i;
        double y;
        for(i=x;i>0;i--)
        {
            y=n/i;
            if(y-(long long int)y==0)
            break;
        }
        cout<<(long long int)i+(long long int)y-2<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000005 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll N;
    cin>>N;
    int n=sqrt(N);
    ll ans=INF;
    for(ll a=1;a<n;a++){
        if(N%a==0){
            ll b=N/a;
            ans=min(ans,a+b-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define Rep(i, s, n) for (ll i = (ll)s; i < (ll)n; i++)
typedef long long ll;

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    ll min = n - 1;
    Rep (i, 2, sqrt(n)) {
        if (n % i == 0) {
            ll j = n / i;
            ll k = (i-1) + (j-1);
            if (min > k) min = k;
        }
    }
    cout << min << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<ll> prime;//素因数分解で出てきた素数を全て挿入するvector

//O(√n)
//整列済み
/*
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
    for(ll i=2; i<=l; i++){
        if(n%i==0){
        prime_factorize(i);
        prime_factorize(ll(n/i));
        return;
        }
    }
    prime.push_back(n);
    return;
}
*/
int main() {
    ll N;
    cin >> N;
    vector<ll> cnt;
    for (ll i=1; i*i<N; i++) {
        if (N%i==0) {
            cnt.push_back(i+N/i-2);
        }
    }
    sort(cnt.begin(),cnt.end());
    cout << cnt[0] << endl;
    /*
    prime_factorize(N);
    ll n = prime.size();
    vector<ll> vec(n);
    vec[0] = prime[0];
    for (ll i=1; i<n; i++) {
        if (prime[i-1]==prime[i]) {
            vec[i]=vec[i-1]*prime[i];
        }
        else {
            vec[i]=prime[i];
        }
    }
    vector<ll> cnt(n);
    for (ll i=0; i<n; i++) {
        cnt[i] = vec[i] + N/vec[i] - 2;
    }
    sort(cnt.begin(),cnt.end());
    cout << cnt[0] << endl;
    */
}


#include<stdio.h>
#include<math.h>

long solve(long n) {
    long m = 1 + n;
    int cl = ceil(sqrt(n));

    long double tmp;
    for (int i = 1; i <= cl; ++i) {
        tmp = (long double)i + (long double)n/(long double)i;
        if (tmp == (long)tmp && m > tmp) {
            m = tmp;
        }
    }

    return m;
}

int main () {
    long n;
    scanf("%ld", &n);
    long m = solve(n);

    printf("%ld\n", m - 2);
}


#include <stdio.h>

int main() {
	long N,ans;
	scanf("%ld",&N);
	ans = N + 1 - 2;
	for (long i = 1; i*i <= N; i++) {
		long double tmp = (long double)N/(long double)i;
		if (tmp == (long int)tmp) {
			long val = tmp + i - 2;
			if (val < ans) {
				ans = val;
			}
		}
	}
	printf("%ld\n",ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t
#include <math.h>

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 20

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

uint64_t get_int(void) {
  uint64_t num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%llu", &num);
#else
#error
#endif
  return num;
}

int main(void) {
    uint64_t num = get_int();
    uint64_t num_2 = sqrt(0.5 + num);
    uint64_t i;
    for(i = num_2; i >= 1; i--) {
        if(num%i) continue;
        printf("%llu\n", i + (num/i) - 2);
        return 0;
    }
    return 0;
}


#include <stdio.h>
#include <math.h>

int main(void)
{
    long n=0,count=0,min=0;
    scanf("%ld",&n);
    for(int i=1;i<sqrt(n);i++){
        if(n%i==0){
            count=(i-1)+(n/i-1);
            if(min>count || min==0) min=count;
        }
    }
    printf("%ld",min);
    return 0;
}


#include<stdio.h>
#define MAXNUM 10000000
int main(void){
  int N,i,j,k;
  int A=MAXNUM;
  int B=MAXNUM;
  scanf("%d",&N);
  for(i=1;i<N/2;i++){
    if(N % i == 0){
      j=i;
      k=N/j;
      if(A+B>=j+k){
        A=j;
        B=k;
      }
    }
  }
  printf("%d",A+B-2);
  return 0;
}


#include<stdio.h>
#define MAXNUM 10000000
int main(void){
  int N,i,j,k;
  int A=MAXNUM;
  int B=MAXNUM;
  scanf("%d",&N);
  for(i=1;i<N;i++){
    if(N % i == 0){
      j=i;
      k=N/j;
      if(A+B>=j+k){
        A=j;
        B=k;
      }
    }
  }
  printf("%d",A+B-2);
  return 0;
}


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let i = Number.POSITIVE_INFINITY
    let j = Number.POSITIVE_INFINITY
    for(let k = 1; k<=Math.ceil(Math.sqrt(n));k++){
        if(n % k == 0){
            let l = n / k
            if(k+l < i+j){
                [i,j] = [k,l]
            }
        }
    }
    console.log(i+j-2)
}
Main()


function factorization(num){
    var dividor=2;
    var workbench=num;
    var ret=[];
    while(workbench>1){
        if(workbench%dividor===0){
            workbench/=dividor;
            ret.push(dividor);
        }else{
            dividor++;
        }
        if(dividor**2>workbench){
            ret.push(workbench);
            break;
        }
    }
    return ret;
}

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var max;
  for(var i=1;i**2<=N;i++){
    if(N%i===0){
      max=i;
    }
  }
  console.log(max+N/max-2);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


'use strict';
function main(input) {
  const N = parseInt(input);
  let distance = N - 1;
  for (let a = 2; a <= Math.sqrt(N); ++a) {
    let b = N / a;
    if (Number.isInteger(b) && a+b-2 < distance) {
      distance = a+b-2;
    }
  }
  console.log(distance);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input){
    input = parseInt(input);
    var i = input;
    i = Math.floor(i/2)+1;
    var array = [];
    while(i--){
        if(input%i === 0){
            array.push((input/i)+i);
        }
    }
    console.log(array.reduce((a,b)=>Math.min(a,b))-2);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)素因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
isPrime(n)素数かどうか真偽値で返します
isNumber(n)数かどうか真偽値で返します
arrsum(arr)配列の合計値を返します
nibu(arr,n)n以下で最も大きい数の添字を返します(nを含みます)
br(input)入力を改行で区切ります
*/
const debugMode = false;
const inf = Number.MAX_SAFE_INTEGER;

function Main(input){
  var n = primeFactorization(input);
  //console.log(n)
  var base = 1;
  var arr = [];
  Object.keys(n).forEach(function(val){
    base *= Math.pow(val,Math.floor(n[val]/2));
    if(n[val]%2==1) arr.push(Number(val));
  });
  arr.length = 20;
  for(var i=0;i<arr.length;i++){
      if(!arr[i]) arr[i] = 1;
  }
  var min = inf;
  var pair = new Array(20).fill(0);
  for(var p1=0;p1<2;p1++){
    for(var p2=0;p2<2;p2++){
      for(var p3=0;p3<2;p3++){
        for(var p4=0;p4<2;p4++){
          for(var p5=0;p5<2;p5++){
            for(var p6=0;p6<2;p6++){
              for(var p7=0;p7<2;p7++){
                for(var p8=0;p8<2;p8++){
                  for(var p9=0;p9<2;p9++){
                    for(var p10=0;p10<2;p10++){
                      for(var p11=0;p11<2;p11++){
                        for(var p12=0;p12<2;p12++){
                          for(var p13=0;p13<2;p13++){
                            for(var p14=0;p14<2;p14++){
                              for(var p15=0;p15<2;p15++){
                                for(var p16=0;p16<2;p16++){
                                  for(var p17=0;p17<2;p17++){
                                    for(var p18=0;p18<2;p18++){
                                      for(var p19=0;p19<2;p19++){
                                        for(var p20=0;p20<2;p20++){

    var a=1;
    var b=1;
    if(p1==0){a*=arr[0]}
    else{b*=arr[0]};
    if(p2==0){a*=arr[1]}
    else{b*=arr[1]};
    if(p3==0){a*=arr[2]}
    else{b*=arr[2]};
    if(p4==0){a*=arr[3]}
    else{b*=arr[3]};
    if(p5==0){a*=arr[4]}
    else{b*=arr[4]};
    if(p6==0){a*=arr[5]}
    else{b*=arr[5]};
    if(p7==0){a*=arr[6]}
    else{b*=arr[6]};
    if(p8==0){a*=arr[7]}
    else{b*=arr[7]};
    if(p9==0){a*=arr[8]}
    else{b*=arr[8]};
    if(p10==0){a*=arr[9]}
    else{b*=arr[9]};
    if(p11==0){a*=arr[10]}
    else{b*=arr[10]};
    if(p12==0){a*=arr[11]}
    else{b*=arr[11]};
    if(p13==0){a*=arr[12]}
    else{b*=arr[12]};
    if(p14==0){a*=arr[13]}
    else{b*=arr[13]};
    if(p15==0){a*=arr[14]}
    else{b*=arr[14]};
    if(p16==0){a*=arr[15]}
    else{b*=arr[15]};
    if(p17==0){a*=arr[16]}
    else{b*=arr[16]};
    if(p18==0){a*=arr[17]}
    else{b*=arr[17]};
    if(p19==0){a*=arr[18]}
    else{b*=arr[18]};
    if(p20==0){a*=arr[19]}
    else{b*=arr[19]};
    if(Math.abs(a-b)<min){
      min = Math.abs(a-b);
      pair = [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20];
    }
  }}
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  a = base;
  b = base;
  for(var j=0;j<20;j++){
    if(pair[j]==1){
      a*=arr[j];
    }else{
      b*=arr[j];
    }
  }
  console.log(a+b-2);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function next(m,now){

}
function zisyozyunn(a){
  var arr = [];
  for(var i=0;i<input[0];i++){
    arr.push(i+1);
  }
  var sum = 0;
  for(var i=0;i<a.length;i++){
    var f = arr.findIndex(val => val==a[i]);
    sum += factorialize(a.length-1-i)*f;
    arr.splice(f,1);
  }
  return sum;
}
function arrsum(arr){
  var sum = 0;
  for (var i=0,len=arr.length; i<len; ++i) {
      sum += arr[i]-0;
  };
  return sum;
}
function debug(val){
  if(debugMode==true){
    console.log(val)
  }
}
function arrMaxPoint(arr){
	var max = Number.MIN_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(max<arr[i]){
			max = arr[i];
			point = i;
		}
	}
	return point;
}
function arrMinPoint(arr){
	var min = Number.MAX_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(min>arr[i]){
			min = arr[i];
			point = i;
		}
	}
	return point;
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}
function isNumber(val){
	const pat = /^([1-9]\d*|0)$/;
	return pat.test(val);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}
function rotate(array) {
  const ROW = array.length;
  const COL = array[0].length;
  const row = ROW-1;
  var a = new Array(COL);
  for (var c=0; c<COL; c++) {
    a[c] = new Array(ROW);
    for (var r=0; r<ROW; r++) {
      a[c][r] = array[row-r][c];
    }
  }
  return a;
}
function part_in(base,push,st){
	for(var i=st,p=0;p<push.length;i++,p++){
		base[i] = push[p];
	}
	return base;
}
function part_reverse(arr,s,g){
	var push = arr.slice(s-1,g);
  push.reverse();
	arr = part_in(arr,push,s-1);
	return arr;
}
function zeroPadding(num,length){
    return (num + '000000000000000000000000000000000').slice(0,length);
}
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i]-0;
    };
    return sum;
}
function pf(n) {
    var result = {};

    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}
function num(a, b) {
  return a - b;
}
function nibu(a,searchValue){
	var index = -1;

//調べる左端を表す添字(index)
var left = 0;

//調べる右端を表す添字(index)
var right = a.length-1;

//左端と右端にデータがある間は処理を繰り返す
while(left <= right){

    //左右の真ん中を表す添字(index)
    middle =Math.floor((left +right)/2);

    //真ん中の値と探す値を比較する
    if(a[middle]==searchValue){
        //一致した場合、変数に入れて処理終了
        index = middle;
        break;
    }else if(a[middle]<searchValue){
        //探す値より小さい場合、左側にはもっと小さい値しかないので左端の値を真ん中の値の右に移動する
        left = middle +1;
    }else{
        //探す値より大きい場合、右側にはもっと大きい値しかないので右端の値を真ん中の値の左に移動する
        right = middle -1;
    }
}
if(index!=-1) return index;
else return left;
}
function br(input){
  return input.split("\n");
}
function is_sortred(arr){
  var flag = true;
  for(var i=1;i<arr.length;i++){
    if(arr[i-1]>arr[i]){
      flag = false;
      break;
    }
  }
  return flag;
}
function primeFactorization(n) {

	// 平方根を保存
	var s = Math.floor(Math.sqrt(n));

	var r = 0;

	var result = {};

	// 2から平方根までの素因数を求める
	for (var i = 2;i <= s;i++) {

		if ((n % i) == 0) {

			r = 0; // 指数カウンタクリア

			do {

				r++; // 指数カウンタプラス

				n = n / i;

			} while ((n % i) == 0);

			// 素因数iを指数とともに保存
			result[i]=r;

		}

	}

	// 残った素数を追加
	if (n > s) {
		result[n] = 1;
	}

	return result;

}


/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)素因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
isPrime(n)素数かどうか真偽値で返します
isNumber(n)数かどうか真偽値で返します
arrsum(arr)配列の合計値を返します
nibu(arr,n)n以下で最も大きい数の添字を返します(nを含みます)
br(input)入力を改行で区切ります
*/
const debugMode = false;
const inf = Number.MAX_SAFE_INTEGER;

function Main(input){
  var n = primeFactorization(input);
  //console.log(n)
  var base = 1;
  var arr = [];
  Object.keys(n).forEach(function(val){
    base *= Math.pow(val,Math.floor(n[val]/2));
    if(n[val]%2==1) arr.push(Number(val));
  });
  arr.length = 18;
  for(var i=0;i<arr.length;i++){
      if(!arr[i]) arr[i] = 1;
  }
  var min = inf;
  var pair = new Array(18).fill(0);
  for(var p1=0;p1<2;p1++){
    for(var p2=0;p2<2;p2++){
      for(var p3=0;p3<2;p3++){
        for(var p4=0;p4<2;p4++){
          for(var p5=0;p5<2;p5++){
            for(var p6=0;p6<2;p6++){
              for(var p7=0;p7<2;p7++){
                for(var p8=0;p8<2;p8++){
                  for(var p9=0;p9<2;p9++){
                    for(var p10=0;p10<2;p10++){
                      for(var p11=0;p11<2;p11++){
                        for(var p12=0;p12<2;p12++){
                          for(var p13=0;p13<2;p13++){
                            for(var p14=0;p14<2;p14++){
                              for(var p15=0;p15<2;p15++){
                                for(var p16=0;p16<2;p16++){
                                  for(var p17=0;p17<2;p17++){
                                    for(var p18=0;p18<2;p18++){

    var a=1;
    var b=1;
    if(p1==0){a*=arr[0]}
    else{b*=arr[0]};
    if(p2==0){a*=arr[1]}
    else{b*=arr[1]};
    if(p3==0){a*=arr[2]}
    else{b*=arr[2]};
    if(p4==0){a*=arr[3]}
    else{b*=arr[3]};
    if(p5==0){a*=arr[4]}
    else{b*=arr[4]};
    if(p6==0){a*=arr[5]}
    else{b*=arr[5]};
    if(p7==0){a*=arr[6]}
    else{b*=arr[6]};
    if(p8==0){a*=arr[7]}
    else{b*=arr[7]};
    if(p9==0){a*=arr[8]}
    else{b*=arr[8]};
    if(p10==0){a*=arr[9]}
    else{b*=arr[9]};
    if(p11==0){a*=arr[10]}
    else{b*=arr[10]};
    if(p12==0){a*=arr[11]}
    else{b*=arr[11]};
    if(p13==0){a*=arr[12]}
    else{b*=arr[12]};
    if(p14==0){a*=arr[13]}
    else{b*=arr[13]};
    if(p15==0){a*=arr[14]}
    else{b*=arr[14]};
    if(p16==0){a*=arr[15]}
    else{b*=arr[15]};
    if(p17==0){a*=arr[16]}
    else{b*=arr[16]};
    if(p18==0){a*=arr[17]}
    else{b*=arr[17]};
    if(Math.abs(a-b)<min){
      min = Math.abs(a-b);
      pair = [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18];
    }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  a = base;
  b = base;
  for(var j=0;j<18;j++){
    if(pair[j]==1){
      a*=arr[j];
    }else{
      b*=arr[j];
    }
  }
  console.log(a+b-2);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function next(m,now){

}
function zisyozyunn(a){
  var arr = [];
  for(var i=0;i<input[0];i++){
    arr.push(i+1);
  }
  var sum = 0;
  for(var i=0;i<a.length;i++){
    var f = arr.findIndex(val => val==a[i]);
    sum += factorialize(a.length-1-i)*f;
    arr.splice(f,1);
  }
  return sum;
}
function arrsum(arr){
  var sum = 0;
  for (var i=0,len=arr.length; i<len; ++i) {
      sum += arr[i]-0;
  };
  return sum;
}
function debug(val){
  if(debugMode==true){
    console.log(val)
  }
}
function arrMaxPoint(arr){
	var max = Number.MIN_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(max<arr[i]){
			max = arr[i];
			point = i;
		}
	}
	return point;
}
function arrMinPoint(arr){
	var min = Number.MAX_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(min>arr[i]){
			min = arr[i];
			point = i;
		}
	}
	return point;
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}
function isNumber(val){
	const pat = /^([1-9]\d*|0)$/;
	return pat.test(val);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}
function rotate(array) {
  const ROW = array.length;
  const COL = array[0].length;
  const row = ROW-1;
  var a = new Array(COL);
  for (var c=0; c<COL; c++) {
    a[c] = new Array(ROW);
    for (var r=0; r<ROW; r++) {
      a[c][r] = array[row-r][c];
    }
  }
  return a;
}
function part_in(base,push,st){
	for(var i=st,p=0;p<push.length;i++,p++){
		base[i] = push[p];
	}
	return base;
}
function part_reverse(arr,s,g){
	var push = arr.slice(s-1,g);
  push.reverse();
	arr = part_in(arr,push,s-1);
	return arr;
}
function zeroPadding(num,length){
    return (num + '000000000000000000000000000000000').slice(0,length);
}
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i]-0;
    };
    return sum;
}
function pf(n) {
    var result = {};

    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}
function num(a, b) {
  return a - b;
}
function nibu(a,searchValue){
	var index = -1;

//調べる左端を表す添字(index)
var left = 0;

//調べる右端を表す添字(index)
var right = a.length-1;

//左端と右端にデータがある間は処理を繰り返す
while(left <= right){

    //左右の真ん中を表す添字(index)
    middle =Math.floor((left +right)/2);

    //真ん中の値と探す値を比較する
    if(a[middle]==searchValue){
        //一致した場合、変数に入れて処理終了
        index = middle;
        break;
    }else if(a[middle]<searchValue){
        //探す値より小さい場合、左側にはもっと小さい値しかないので左端の値を真ん中の値の右に移動する
        left = middle +1;
    }else{
        //探す値より大きい場合、右側にはもっと大きい値しかないので右端の値を真ん中の値の左に移動する
        right = middle -1;
    }
}
if(index!=-1) return index;
else return left;
}
function br(input){
  return input.split("\n");
}
function is_sortred(arr){
  var flag = true;
  for(var i=1;i<arr.length;i++){
    if(arr[i-1]>arr[i]){
      flag = false;
      break;
    }
  }
  return flag;
}
function primeFactorization(n) {

	// 平方根を保存
	var s = Math.floor(Math.sqrt(n));

	var r = 0;

	var result = {};

	// 2から平方根までの素因数を求める
	for (var i = 2;i <= s;i++) {

		if ((n % i) == 0) {

			r = 0; // 指数カウンタクリア

			do {

				r++; // 指数カウンタプラス

				n = n / i;

			} while ((n % i) == 0);

			// 素因数iを指数とともに保存
			result[i]=r;

		}

	}

	// 残った素数を追加
	if (n > s) {
		result[n] = 1;
	}

	return result;

}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	var divisor int
	root := int(math.Floor(math.Sqrt(float64(N))))
	//fmt.Println(root)
	for i := 1; i <= root; i++ {
		if N%i == 0 {
			divisor = i
		}
	}
	quotient := N / divisor
	// fmt.Println(quotient, divisor)
	fmt.Println(quotient + divisor - 2)
}


package main

import(
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    if isPrime2(n) {
        fmt.Println(n-1)
        return
    }
    for i:= int(math.Sqrt(float64(n)));i > 0;i-- {
        if n % i == 0 {
            fmt.Println(i+n/i-2)
            return
        }
    }
}

func isPrime2(x int) bool {
    if x == 1 {
        return false
    }
    if x == 2 {
        return true
    }
    if x%2 == 0 {
        return false
    }

    b := true
    rootx := int(math.Sqrt(float64(x)))
    i := 3
    for i <= rootx {
        if x%i == 0 {
            b = false
            break
        }
        i += 2
    }
    return b
}


package main
import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	m := int(math.Ceil(math.Sqrt(float64(n))))
	for j := m; ; j-- {
		if n % j == 0 {
			i := n / j
			d := (i-1) + (j-1)
			fmt.Println(d)
			return
		}
	}
}


package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Walk on Multiplication Table
	var N int
	fmt.Scanf("%d", &N)

	var ans int
	var min int = 100000000000
	for i := 1; float64(i) <= math.Sqrt(float64(N)); i++ {
		if N%i != 0 {
			continue
		} else {
			j := N / i
			ans = (i - 1) + (j - 1)

			if min > ans {
				min = ans
			}
		}
	}

	fmt.Println(min)
}


package main

import "fmt"

func main() {
	// Code for C - Walk on Multiplication Table
	var N int
	fmt.Scanf("%d", &N)

	var ans int
	var min int = 10000000
	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			if i*j == N {
				ans = (i - 1) + (j - 1)
			}

			if min > ans {
				min = ans
			}
		}
	}

	fmt.Println(min)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	min := n
	for i:=1; i<=n; i++{
		for j:=i+1; j<=n; j++{
			if i*j == n && (i-1)+(j-1) < min{
				min = (i-1)+(j-1)
				break
			}
		}
	}

	fmt.Println(min)
}


# a * b = N
# ans = a - 1 + b - 1の最小値
n = gets.to_i
a = Math.sqrt(n).to_i
while n % a != 0
  a -= 1
end
b = n / a
puts a + b - 2


N = gets.to_i
i = Math.sqrt(N).to_i

while N % i != 0
  i -= 1
end

puts i + N/i -2


n = gets.to_i
a = Math.sqrt(n).to_i

while n % a != 0
  a -= 1
end

b = n / a
puts a + b - 2


def divisor(num_sqrt)
    (1..num_sqrt).select{ |i| num_sqrt % i == 0 }
end

num = gets.to_i
num_sqrt = Math.sqrt(num).floor
divisions = divisor(num_sqrt)

distance_lists = []

for d in divisions do
  width_count = (d - 1)
  vertical_count = (num / d - 1)
  distance_lists << width_count + vertical_count
end

ans = distance_lists.min
puts(ans)


def divisor(num_sqrt)
    result = []
    i = 1
    while i <= num_sqrt do
      remainder = num_sqrt % i
      if remainder == 0
        result << i
      end
      i += 1
    end
    return result
end

num = gets.to_i
num_sqrt = Math.sqrt(num).floor
divisions = divisor(num_sqrt)

distance_lists = []

for d in divisions do
  width_count = (d - 1)
  vertical_count = (num / d - 1)
  distance_lists << width_count + vertical_count
end

ans = distance_lists.min
puts(ans)


#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let mut sq_n = 0;
    for i in 1..n {
        if i * i > n {
            sq_n = i;
            break;
        }
    }
    if n == 2 {
        println!("1");
        return;
    }
    let primes = get_primes(sq_n as usize);
    let fact_dict = factorize(n, &primes);
    let factors = collect_all_factors(&fact_dict);
    let mut ans_pair = (1, n);
    for num in factors {
        if (ans_pair.0 - 1) + (ans_pair.1 - 1) > (num - 1) + (n / num - 1) {
            ans_pair = (num, n / num);
        }
    }
    println!("{}", (ans_pair.0 - 1) + (ans_pair.1 - 1));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn get_primes(n: usize) -> Vec<i64> {
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        if is_prime[i] {
            primes.push(i as i64);
            let mut j = 2 * i;
            while j < n {
                is_prime[j] = false;
                j += i;
            }
        }
    }
    primes
}

fn factorize(mut num: i64, primes: &Vec<i64>) -> std::collections::HashMap<i64, i64> {
    // max_primes >= (num)^(1/2)
    let mut dict = std::collections::HashMap::new();
    for &p in primes.iter() {
        while num % p == 0 {
            *dict.entry(p).or_insert(0) += 1;
            num /= p;
        }
        if num == 1 {
            break;
        }
    }
    if num != 1 {
        dict.insert(num, 1);
    }
    dict
}

fn pow(n: i64, mut p: i64) -> i64 {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r;
            p /= 2;
        } else {
            ret = ret * r;
            p -= 1;
        }
    }
    ret
}

fn collect_all_factors(dict: &std::collections::HashMap<i64, i64>) -> Vec<i64> {
    let mut ret = vec![1];
    for &key in dict.keys() {
        let mut new = ret.clone();

        for coef in 1..dict[&key] + 1 {
            let coef_1 = pow(key, coef);
            for &num in ret.iter() {
                new.push(num * coef_1);
            }
        }
        ret = new;
    }
    ret
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();

    let mut ans = std::usize::MAX;

    for a in 1..(n as f64).sqrt().ceil() as usize +1{
        if n % a == 0 {
            ans = std::cmp::min(ans, n/a + a - 2);
        }
    }

    println!("{}", ans);

}


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
    }

    let mut ans = n+1;
    let max_range = (n as f64).sqrt().ceil() as usize;
    for i in 1..max_range+1{
        if n % i == 0 {
            let d = n / i;
            ans = std::cmp::min(ans, d+i);
        }
    }

    println!("{}", ans-2);

}


use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut ans = std::usize::MAX;

    for i in 1..=((n as f64).sqrt().floor()) as usize {
        for k in 1..=n {
            if i * k == n {
                ans = ans.min(i + k - 2);
            }
        }
    }
    println!("{}", ans);
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: u128};

    let half_n = (n as f64).sqrt() as usize;

    let mut dis = std::u128::MAX;

    for i in 1..half_n {
        if n % i as u128 == 0 {
            let x = n / i as u128;
            dis = std::cmp::min(dis, x + i as u128 - 2)
        }
    }

    println!("{}", dis);
}


use proconio::input;

fn main() {
  input! {
    n: usize
  }

  let mut a = 1;
  let mut b = n;
  let mut min = usize::max_value();
  while a < b {
    if n % a == 0 {
      min = std::cmp::min(min, (a - 1) + (n / a - 1));
    }
    a += 1;
    b = n / a;
  }

  println!("{}", min);
}


import CoreFoundation
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

let n = arr[0]

var move = 0
var min = n
for i in 1...Int(sqrt(Double(n))) {
  if( ( n % i ) == 0 ) {
    if( ( n / i ) + i - 2 < min ) {
      min = ( n / i ) + i - 2
    }
  }
}

print( min )


import Foundation
// 第一引数には約数を列挙したい自然数を渡す
func print_divisors(n:Int)->[Int]{
    // 戻り値となる配列の初期化
    var divisors:[Int] = []
    // ループを回すのは√nまでで十分
    for i in 1...Int(sqrt(Double(n))){
        // 割り切れるならiはnの約数
        if n % i == 0{
            divisors.append(i)
            // i != n / i なら i^2 != n
            if i != n / i{
                divisors.append(n/i)
            }
        }
    }
    // 配列をソートする
    divisors.sort{ $0 < $1 }
    // divisorsを返す
    return divisors
}

// 標準入力の受け取り
let n = Int(readLine()!)!

// 約数列挙
let check = print_divisors(n:n)

// 答えとなる変数ansの初期化 (とりあえずめっちゃでかい値入れておく)
var ans = 100000000000000

// 各約数についてループを回す
for i in check{

    // ループは √n までで十分
    if i > Int(sqrt(Double(n))){
        break
    }

    // より小さい値をansに代入
    ans = min(ans,i+n/i-2)
}

// 答えを返す
print(ans)


// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}
// https://melheaven.hatenadiary.jp/entry/atcoder144
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }

    return divisors
}

func main() {
    let n = readInt()
    let ary = makeDivisors(n)
    print(ary.min()! - 2)
}
main()


// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

func main() {
    let n = readInt()

    if (isPrime(n)) && Int(sqrt(Double(n))) == n {
        print(n - 1)
        return
    }
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > a + b - 2  {
        ans = a + b - 2
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }

    print(a + b - 2)
}
main()


// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

func main() {
    let n = readInt()

    if (isPrime(n)) && Int(sqrt(Double(n))) == n {
        print(n - 1)
        return
    }
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > a + b - 2  {
        print(ans,a,b)
        ans = a + b - 2
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }

    print(a + b - 2)
}
main()


// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

func main() {
    let n = readInt()

    if (isPrime(n)) {
        print(n - 1)
        return
    }
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > (a - 1) + (b - 1) {
        ans = (a - 1) + (b - 1)
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }

    print((a - 1) + (b - 1))
}
main()


const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};const deduplicate=(a:number[])=>{return Array.from(new Set(a))};const permutation=(arr,n)=>{var arrs,i,j,zensu,results,parts;arrs=[];zensu=arr.length;if(zensu<n){return}else if(n==1){for(i=0;i<zensu;i++){arrs[i]=[arr[i]]}}else{for(i=0;i<zensu;i++){parts=arr.slice(0);parts.splice(i,1)[0];results=permutation(parts,n-1);for(j=0;j<results.length;j++){arrs.push([arr[i]].concat(results[j]))}}}return arrs}
const main=()=>{
  let n=tn(),ans=n;
  let y=n,xx=1,yy=n
  for(let x=1;x<=y;x++){
    y=n/x
    if(Number.isInteger(y)){
      xx=x
      yy=y
    }
  }
  to(xx+yy-2)
}
main()


function main(input: string[]): void {
    const n = parseInt(input.shift());
    let min = n * 2;
    let log = Math.ceil(Math.sqrt(n));
    for (let i = 1; i <= log; i++) {
        if (n % i === 0) {
            min = Math.min(min, i + Math.round(n / i));
            //puts(i, i + n / i, min);
        }
    }
    puts(min - 2);
}

// === BEGIN MODULE ===
function puts(...message: any[]): void {
    console.log(message.join(' '));
}
// === END   MODULE ===

import { readFileSync } from 'fs';
if (process.argv[1] == __filename) {
    const path = process.argv[2] || '/dev/stdin';
    const input = readFileSync(path, 'utf-8');
    main(input.split(/\s+/));
}


function main(p){
  const num = parseInt(p.split('\n')[0], 10)
  let ans
  for (let i=1; i<=Math.sqrt(num); i++){
    if(num % i === 0){
      ans = num/i + i - 2
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const { pairs } = _divisor(N)

    let res = Infinity

    pairs.forEach(([a, b]) => {
      const k = a + b - 2

      res = Math.min(res, k)
    })
    console.log(res)
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }
  const _divisor = (n: number) => {
    const sq = Math.floor(Math.sqrt(n))
    const list: number[] = []
    const pairs: [number, number][] = []

    if (n % sq === 0) {
      list.push(sq)
      pairs.push([sq, sq])
    }
    for (let i = sq - 1; i > 0; i--) {
      if (n % i === 0) {
        list.unshift(i)
        list.push(n / i)
        pairs.unshift([i, n / i])
      }
    }
    return { list, pairs }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


const main = (input) => {
  const n = Number(input)
  let result = n-1
  for (let i = 1; i*i < n; i++) {
    if (n%i === 0) {
    　const num = i + n/i - 2
      result = num < result ? num : result
    }
  }
  console.log(result)

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


'use strict'
function main(input: string) {
    const n: number = Number(input.split('\n')[0]);
    let s: string[] = [];
    for (let i = 1; i <= n; i++) {
        s.push(input.split('\n')[i].split('').sort().join(''));
    }
    let r = 0;
    let tmp = {};
    s.forEach(v => {
        if (v in tmp) {
            r += tmp[v];
            tmp[v]++;
        } else {
            tmp[v] = 1;
        }
    });
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


N = int(input())
if N%2 == 0:
    print(N)
else:
    print(2*N)


N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N * 2)


N = input()

i = N + 1
while True:
    if(i % 2 == 0 and i % N == 0):
        break
    i = i + 1

print(i)


import math
N=int(input())
print(2*N//gcd(2,N))


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(problem102a(n));
    }

    private static int problem102a(int n) {
        return (n % 2 == 0) ? n : (n * 2);
    }
}


import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println(N % 2 == 0 ? N : 2 * N);
        }
    }
}


import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        if (n % 2 == 0) System.out.println(n);
        else System.out.println(n*2);
    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] numbers = new int[N];

		for(int j = 0; j <numbers.length; j++) {
			numbers[j] = sc.nextInt();
		}

		int max = numbers[0];
		int min = numbers[0];

		for(int i = 1; i < numbers.length; i++ ) {
			if(numbers[i] > max ) {
				max = numbers[i];
			}
			if(numbers[i] < min ) {
				min = numbers[i];
			}
		}
		System.out.println(max-min);
	}

}


import java.util.*;
import java.io.*;

public class Main {
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		public long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}

	static final FS sc = new FS();
	static final PrintWriter out = new PrintWriter(System.out);
	static final int mod = 1000000007;

	public static void main(String[] args) {
		solve();
		out.close();
	}

	static void solve() {
		long n = sc.nextInt();
		long i = n;
		while(true) {
			if(i % n == 0 && i % 2 == 0) {
				out.println(i);
				break;
			}
			else i++;
		}

	}

	}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 2; i <= Integer.MAX_VALUE; i+=2) {
            if (i%2==0 && i%n==0) {
                System.out.println(i);
                return;
            }
        }
    }
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

int main()
{
	scanf("%d",&n);
	if(n%2==1)n *= 2;
	printf("%d\n",n);
	return 0;
}


#include<stdio.h>

int main()
{
	int N;
	scanf("%d",&N);

	if(N%2==0)
		printf("%d\n",N);
	else
		printf("%d\n",N*2);

	return 0;
}


#include<stdio.h>
#include<stdlib.h>

int main()
{
	int x;
	int answer = 1;
	scanf("%d", &x);

		if (x % 2 == 0)
		{
			answer = x;
			goto exit;
		}
		else
		{
			answer = 2 * x;
		}
exit:
	printf("%d", answer);

	return 0;
}


/******************************************
* AUTHOR : ARPIT *
* NICK : arpitfalcon *
* INSTITUTION : BIT MESRA *
* Ab m game m hu. *
******************************************/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 -
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vin                    \
    ll n;                      \
    cin >> n;                  \
    vector<ll> x(n);           \
    for (ll i = 0; i < n; i++) \
    cin >> x[i]
#define vout                   \
    for (ll i = 0; i < n; i++) \
    cout << x[i] << " "
#define T     \
    ll t = 1; \
    cin >> t; \
    while (t--)
#define ain                    \
    ll n, k;                   \
    cin >> n >> k;             \
    ll a[n];                   \
    for (ll z = 0; z < n; z++) \
    cin >> a[z]
#define aout                   \
    for (ll i = 0; i < n; i++) \
    cout << a[i] << " "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define max4(a, b, c, d) max(a, max3(b, c, d))
#define min4(a, b, c, d) min(a, min3(b, c, d))
#define blink                \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI = 3.141592653589793238463;

#define forn(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define for1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define forr(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))

/*
__builtin_ffs(x)
  Number of set bits: __builtin_popcount(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
*/

int main()
{
    blink
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    // your code goes here
    int n;
    cin >> n;
    if (n % 2)
    {
        cout << n;
    }
    else
    {
        cout << n * 2;
    }

    return 0;
}


#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

int main() {
	int N;
	cin >> N;

	if (N % N == 0) {
		cout << N;
	}
	else
	cout << N * 2 << endl;
}


#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

int main() {
	int N;
	cin >> N;

	cout << N * 2 << endl;
}


#include <stdio.h>

int main()
{
  int N;
  scanf("%d",&N);
  if(N % 2 == 0){
      printf("%d",N);
  }else{
      printf("%d",2*N);
  }
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
int main (void){
        long long int N;
          scanf("%lld",&N);
          if (N%2==1) {
            N*=2;
          }

        printf("%lld\n",N);

        return 0;

}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n%2==0)
        printf("%d\n",n);
    else
        printf("%d\n",2*n);

    return 0;
}


#include<iostream>

using namespace std;

int main(){
    long long n;
    cin >> n;
    if(n%2==1)printf("%lld\n", n*2);
    else printf("%lld\n", n);
    return 0;
}


#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n)+
    if(n%2==0){
      printf("%d\n",n);
    }else{
      printf("%d\n",2*n);
    }
  return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int a;
    scanf("%4d",&a);
    if (a%2==0) printf("%d",a);
    else printf("%d",a*2);

    return 0;
}


// inputに入力データ全体が入る
function Main(str) {
  const num = Number(str);

  if (num <= 2) {
    console.log(2);
    return;
  }

  if (num % 2 === 0) {
    console.log(num);
    return;
  }

  console.log(num * 2);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
  const N = parseInt(input.split(" ")[0], 10);
  if(N%2==0){
    console.log(N);
  }else{
    console.log(2*N);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


'use strict'

function main(input){
    const N = Number(input[0]);
    console.log((N%2+1)*N);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))


const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])
  for (let i = 2; ; i += 2) {
    if (i % N === 0) {
      console.log(i)
      break
    }
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;

  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	if(N % 2 == 1){
		N++;
	}
	myout(N);
}


'use strict'
function Main(input) {
	const A = input.split('\n')[1].split(' ').map(Number);
  	console.log(Math.max(...A) - Math.min(...A));
}
Main(require('fs').readFileSync("/dev/stdin", "utf8"));


package main

import (
    . "fmt"
)

func main() {
    var n int
    Scanf("%d", &n)

    if n % 2 == 0 {
        Println(n)
    } else {
        Println(n * 2)
    }
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()

	if N % 2 == 0 {
		fmt.Println(N)
	} else {
		fmt.Println(N*2)
	}
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for _, v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n%2 == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(n * 2)
	}
}


package main

import (
	"fmt"
)

func main() {

	var N int

	fmt.Scan(&N)

	fmt.Print(N * 2)

}


package main

import (
	"fmt"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func main() {
	var n int64
	fmt.Scan(&n)

	var ans int64 = min(2, n)
	for {
		if ans%2 == 0 && ans%n == 0 {
			fmt.Println(ans)
			return
		}
		ans += min(2, n)
	}
}


package main

import (
	"fmt"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func main() {
	var n int64
	fmt.Scan(&n)

	var ans int64 = min(2, n)
	for {
		if ans%2 == 0 && ans%n == 0 {
			fmt.Println(ans)
			return
		}
		ans += max(2, n)
	}
}


p 2.lcm(gets.to_i)


N = gets.to_i

if N % 2 == 0
  puts N
else
  puts 2 * N
end


n = gets.strip.to_i
puts (n % 2 != 0) ? 2 * n : n


n = gets.to_i
puts n.lcd(2)


n=gets.chomp
if n%2==0
  p n
else
  p n*2
end


n = gets.to_i

print n % 2 == 0 ? n : n+1


use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let n = v[0];
	if n%2 == 0 {
		println!("{}", n);
	}else{
		println!("{}", 2*n);
	}
}


use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    println!("{}", n * ((n % 2) + 1));
}


fn main() {
    let n = read::<usize>();
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  print $ if n `mod` 2 == 0 then n else 2 * n


// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"3"# => "6",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }

    let mut ans:usize = 0;
    let mut i:usize = 2;

    while ans == 0 {
        if i % n == 0 && i % 2 == 0 {
            ans += i;
            break;
        }
        i += 2;
    }
    ans.to_string()
}


// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"999999999"# => "1999999998",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: u64,
    }

    let mut ans:u64 = 0;
    let mut i:u64 = 2;

    while i <= 1_000_000_000 {
        if i % n == 0 && i % 2 == 0 {
            ans += i;
            break;
        }
        i *= 2;
    }
    ans.to_string()
}


//let i=Int(readLine()!)!%2;print(i%2>0 ?i*2:i)
let N = Int(readLine()!)!
var ans = 0
if N % 2 == 0 {
	ans = N
} else {
	ans = N * 2
}
print(ans)


let N=Int(readLine()!)!;print(N%2>0 ?N*2:N)


let N=Int(readLine()!)!
if (N%2==0){
  print(N)
}else{
  print(2*N)
}


let s = Int(readLine()!)!
let t = readLine()!.split(separator: " ").map({Int($0)!})
let max = t.max()!
let min = t.min()!
print(max - min)


var N=Int(readLine()!)!;N%2>0 ?N*=2:;print(N)


var N=Int(readLine()!)!;N%2>0 ?N*=2:break;print(N)


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

console.log(n % 2 === 0 ? n : n * 2)


const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let n=nin()
  if(n%2==0)out(n)
  else out(n*2)
}
main();


const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const n = parseInt(input[0], 10);

  if(n%2===0){
    console.log(n);
  }else{
    console.log(2*n);
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const n = paeseInt(input[0], 10);

  if(n%2===0){
    console.log(n);
  }else{
    console.log(2*n);
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const n = paeseInt(input[0], 10);

  if(N%2===0){
    console.log(n);
  }else{
    console.log(2*n);
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

let i = 1
while(1){
  if(i % 2 === 0 && i % n === 0) break
  i++
}

console.log(i)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, input().split())
a = [10 ** 10] + list(map(int, input().split()))
b = [10 ** 10] + list(map(int, input().split()))
ans = 10 ** 10
for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x] + b[y] - c)
ans = min(ans, min(a) + min(b))

print(ans)


import math

def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())

    abm = [int(x) for x in input().rstrip().split(" ")]
    a_list = [int(x) for x in input().rstrip().split(" ")]
    b_list = [int(x) for x in input().rstrip().split(" ")]

    # 最小値
    ans = min(a_list) + min(b_list)

    for i in range(abm[2]):
        xyc = [int(x) for x in input().rstrip().split(" ")]
        price = a_list[xyc[0] - 1] + b_list[xyc[1] - 1] - xyc[2]
        if price < ans:
            ans = price

    print(ans)

if __name__ == "__main__":
    resolve()


#!/usr/bin/env python3
import sys

def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    ans = min(a) + min(b)
    for i in range(M):
        xi = x[i]
        yi = y[i]
        ci = c[i]
        t = a[xi-1] + b[yi-1] - ci
        if ans >= t:
            ans = t
    print(ans)
    return

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()


A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
price_list = []

for s in a:
  for t in b:
    price_list.append(s + t)

for i in range(M):
  x, y, c = map(int, input().split())
  price = a[x-1] + b[y-1] - c
  price_list.append(price)

min_price = price_list[0]

for n in price_list:
  if min_price >= n:
    min_price = n
  elif min_price < n:
    pass

print(min_price)


A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = []
y = []
c = []
for _ in range(M):
    X,Y,Z = map(int,input().split())
    x.append(X)
    y.append(Y)
    c.append(Z)

mini = min(a) + min(b)
for i in range(M):

    rei = a[x[i]-1]
    den = b[y[i]-1]
    coop = c[i-1]

    if rei + den - coop < mini:
        mini = rei + den - coop

print(mini)


A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = []
y = []
c = []
for _ in range(M):
    X,Y,Z = map(int,input().split())
    x.append(X)
    y.append(Y)
    c.append(Z)

mini = max(a) + max(b)
for i in range(M):
    if a[x[i]-1] + b[y[i]-1] - c[i-1] < mini:
        mini = a[x[i]-1] + b[y[i]-1] - c[i-1]

print(min(mini,min(a) + min(b)))