import java.util.Scanner;

public class Lazy_Security_Guard_Takua {
    static Scanner in= new Scanner (System.in);

	public static void main(String[] args) {
		double n=in.nextInt();

		double w=Math.ceil(Math.sqrt(n));
		double h=Math.ceil(n/w);

				System.out.println(2*((int)w+(int)h));

	}

}

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Basic {
    static final int four = 4;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = scan.nextInt();
        double value =  Math.sqrt(input);
        if(value % 1 == 0){
            value = value * four;
        }else{
            value = (int) value;
            int valueTemp = (int) value * (int) value;
            if((input - valueTemp) <= value){
                value = (int) value * four + 2;
            }else{
                value = (int) value * four + 4;
            }
        }
        System.out.println((int)value);
        }
}

import java.io.IOException;
import java.util.Scanner;

public class codforces {

	public static void main(String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	long t = sc.nextLong();
    	long somme = 1;
    	long per ;
    	long i=2;
    	while(somme<=t){
    		if(somme==t) break;
    		somme = i*i;
    		i++;
    	}

    	if(t==1){per = 4; System.out.println(per);}
    	else if(t==2){per=6;System.out.println(per);}
    	else if(t==3){ per = 8;System.out.println(per);}

    	else if(somme ==t ) { i=i-1 ; System.out.println( ( i*i*4  -  i*(i-1)*4 ));}
    	else { i=i-2 ;
    		 if(t-i*i > i){ System.out.println(i*i*4  -  i*(i-1)*4 + 4);}
    		 else System.out.println(i*i*4  -  i*(i-1)*4 + 2);}

}
}

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

public class SecurityGuard {
  public static void main(String[] args) throws IOException {
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(bf.readLine());

    int root = (int) Math.sqrt(n);

    if (root * root == n) {
      System.out.println(root * 4);
    } else {
      int lower = root;
      int upper = root + 1;

      int ans = 4 * lower;

      lower *= lower;
      upper *= upper;

      int middle = (upper - lower) / 2 + lower;

      ans = (n <= middle) ? (ans + 2):(ans + 4);
      System.out.println(ans);
    }
  }

}

import java.util.*;
import java.math.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class a{
     static int[] count,count1,count2;
     static Node[] nodes;
     static long[] arr;
     static char[] ch,ch1;
     static long[] darr,farr;
     static Character[][] mat,mat1;
     static long x,h;
     static long maxl;
     static double dec;
     static String s;
     static long minl;
     static int mx = (int)1e9+5;
     static long mod = 998244353l;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static long a;
     static long b;
     static long c;
     static long d;
     static long y,z;
     static int m;
     static long k;
     static String[] str,str1;
     static SortedSet<Character> set,set3,set2;
     static SortedSet<String> set1;
     static List<Integer> list,list1,list2;
     static LinkedList<Character> ll;
     static Map<String,String> map;
     static StringBuilder sb,sb1,sb2;
     static int[] dx = {0,-1,0,1};
     static int[] dy = {-1,0,1,0};

     // public static boolean solve(){

     // }

     public static long solve(){

        long side = (long)Math.sqrt(n);

        if(side*side == n)
            return 4*side;

        else if(side*(side+1) >= n)
            return 2*(side+side+1);

        return 2*(2*side+2);

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();
            // Scanner sc = new Scanner(System.in);
            // int t = sc.nextInt();
            int t = 1;
            // int l = 1;
            while(t > 0){

                n = sc.nextInt();
                // n = sc.nextLong();
                // a = sc.nextLong();
                // b = sc.nextLong();
                // c = sc.nextLong();
                // d = sc.nextLong();

                // x = sc.nextLong();
                // y = sc.nextLong();

                // n = sc.nextLong();
                // n = sc.nextInt();
                // // n1 = sc.nextInt();

                // m = sc.nextInt();

                // k = sc.nextLong();
                // s = sc.next();

                // ch = sc.next().toCharArray();
                // ch1 = sc.next().toCharArray();

                // arr = new long[n];
                // for(int i = 0 ; i < n ; i++){
                //     arr[i] = sc.nextLong();
                // }

                // darr = new long[n];
                // for(int i = 0; i < n ; i++){
                //     darr[i] = sc.nextLong();
                // }

                // farr = new int[n];
                // for(int i = 0; i < n ; i++){
                //     farr[i] = sc.nextInt();
                // }

                // mat = new Character[n][m];
                // for(int i = 0 ; i < n ; i++){
                //     String s = sc.next();
                //     for(int j = 0 ; j < m ; j++){
                //         mat[i][j] = s.charAt(j);
                //     }
                // }
                // str = new String[n];
                // for(int i = 0 ; i < n ; i++)
                //     str[i] = sc.next();

                // nodes = new Node[n];
                // for(int i = 0 ; i < n ;i++)
                //     nodes[i] = new node(sc.nextInt(),sc.nextInt());

                // System.out.println(solve()?"YES":"NO");
                 // solve();
                 System.out.println(solve());
                 t -= 1;
            }

     }

    public static int log(long n){

         if(n == 0 || n == 1)
             return 0;

         if(n == 2)
             return 1;

         double num = Math.log(n);
         double den = Math.log(2);

         if(den == 0)
             return 0;

         return (int)(num/den);
     }

    public static boolean isPrime(long n) {
    // Corner cases
        if (n <= 1)
            return false;

        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n%2 == 0 || n%3 == 0)
            return false;

        for (int i=5; i*i<=n; i=i+6)
            if (n%i == 0 || n%(i+2) == 0)
               return false;

        return true;
    }

     public static long gcd(long a,long b){

        if(b%a == 0)
            return a;

        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // }

    static final Random random=new Random();

    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        Integer first;
        Integer second;
        Node(Integer f,Integer s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                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());
                }
                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());
                }
        }

}

import java.util.Scanner;

public class LazyGuard {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();

        double middle = ((int) Math.sqrt(num)) + 0.5;
        double index = 0;

        if (Math.sqrt(num) < middle) { //round up
            index = Math.floor(Math.sqrt(num));
        }
        else {
            index = Math.ceil(Math.sqrt(num));
        }

        int parameter = (int) index * 4;

        if ((index * index) < num) {
            parameter += 2;
        }

        System.out.println(parameter);

        scanner.close();
    }
}

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

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        int temp = 0;
        int square = 0;
        try {
            int N = Integer.parseInt(br.readLine());
            square = (int)Math.ceil(Math.sqrt(N));
            temp = square * square - N;
        } catch (IOException e) {
            e.printStackTrace();
        }

        output = square * 4;
        if (temp >= square) {
            output -= 2;
        }

        System.out.println(output);
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class Codecheff
{
    public static long minPerimeter(int n)
    {
        int l = (int) Math.sqrt(n);
        int sq = l * l;

        if (sq == n)
            return l * 4;
        else
        {
            long row = n / l;
            long perimeter = 2 * (l + row);

            if (n % l != 0)
                perimeter += 2;
            return perimeter;
        }
    }
    public static void main(String[] args)
   {
       try {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        System.out.println(Codecheff.minPerimeter(n));

        } catch(Exception e) {
        return;}
    }

}

/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner in =new Scanner(System.in);
		int n=in.nextInt();
		double k=Math.sqrt(n);
		double ce=Math.ceil(k);
		double fl=Math.floor(k);
		int c=(int)ce;
		int f=(int)fl;
		//System.out.println(k+" "+ce+" "+fl);
		if(c==f)System.out.println(4*c);
		else
		{
			if(ce-k>=k-fl)
			{
				int ans=2*f;
				int a=n/f;
				ans+=2*a;
				int re=n%f;
				if(re!=0)
				ans+=2;
				System.out.println(ans);
			}
			else
			{
				int ans=2*c;
				int a=n/c;
				//System.out.println(a);
				ans+=2*a;
				int re=n%c;
				if(re!=0)
				ans+=2;
				System.out.println(ans);
			}
		}
	}
}

import java.util.*;

public class LazySecurityGuard {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int lower = (int) Math.floor( Math.sqrt(N) ) ;

		int remaining = N - (lower * lower);

		int perimeter = 0;

		if(remaining > lower)
		{
			perimeter = ( lower + 1 ) * 4;
		}
		else if(remaining == 0)
		{
			perimeter = lower * 4;
		}
		else
		{
			perimeter = (lower * 4) + 2;
		}

		System.out.println(perimeter);

	}

}

import java.util.Scanner;

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

		int square = 0;
		int justOver = 0;

		if(n == 3) {
			System.out.println(8);
			System.exit(0);
		}

		for (int i = 1; i < 1001; i++) {
			if (i * i == n) {
				square = i;
			}
			else if (i * i < n) {
				justOver = i;

			}
		}

		if (square != 0) {
			System.out.println(4 * square);
			System.exit(0);
		}
		else {
			int retVal = justOver * 4;
			int amountOver = justOver * 4;

			int blocksLeft = n - (justOver * justOver);
			for (int i = 0; i < blocksLeft; i++) {
				if (i == 0) {
					retVal += 2;

				}
				else if (i == justOver) {
					retVal += 2;
				}

			}
			System.out.println(retVal);
		}

	}
}

import java.util.*;
import java.io.*;
public class lazy {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader in = new BufferedReader(new FileReader("test.in"));
		PrintStream out = System.out;
		String line = in.readLine().trim(), lines[];

		int n = Integer.parseInt(line), ans = 0;
		for (int i = 0; i <= n; i++) {
			if (i * i >= n) {
				out.println(4 * i);
				break;
			}
			if (i * (i + 1) >= n) {
				out.println(2 * (i + i + 1));
				break;
			}
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Liavontsi Brechka
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static
    @SuppressWarnings("Duplicates")
    class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long square = getSquare(n);
            n -= (square * square);

            if (n != 0) {
                long res = (square + 1) * 4;
                if (n <= square) res -= 2;
                out.print(res);
            } else {
                out.print(square * 4);
            }
        }

        private long getSquare(long n) {
            long square = 1;
            while ((square + 1) * (square + 1) < n) square++;
            return square;
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}

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

public class LazySecurityGuard {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int N = sc.nextInt();

        if (Math.sqrt(N) %1 == 0){
            long y =(long) Math.sqrt(N);
            System.out.println(4*y); return;
        }

        int firstsquare = 0 ;
        for ( int i =N ; i>= 0 ;i--)
            if (Math.sqrt((double)i) %1 ==0){
                firstsquare = i;
                break;
            }
        int temp = N ;
        temp -= firstsquare;

        long side =(long) Math.sqrt((double)firstsquare) ;
        long mohit = 4*side;

        if (temp <= side){
            System.out.println(mohit+2); return ;
        }

        else if(temp <= side*2){
            System.out.println(mohit+4); return;
        }
        else if (temp <= side*3){
            System.out.println(mohit +6); return;
        }
        else {
            System.out.println(mohit +8); return;
        }

    }
}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class Es
{
	static class Pair
	{
		int first, second;
		public Pair(int f, int s)
		{
			first = f;
			second = s;
		}

		public String toString()
		{
			return first + " " + second;
		}
	}

	static class PairComparator implements Comparator <Pair>
	{
		public int compare(Pair p1, Pair p2)
		{
			if(p1.first < p2.first)
				return -1;
			if(p1.first > p2.first)
				return 1;
			if(p1.second < p2.second)
				return -1;
			if(p1.second > p2.second)
				return 1;
			return 0;
		}
	}

	static int log2(double a)
	{
		return (int)(Math.log(a) / Math.log(2));
	}

	static long gcd(long a, long b)
	{
		long r;
		while((r = a % b) > 0)
		{
			a = b;
			b = r;
		}
		return b;
	}

	static class TrieNode
	{
		TrieNode z, o;
		boolean end;
		long count;

		public TrieNode()
		{
			 z = null;
			 o = null;
			 count = 0;
			 end = false;
		}
	}

	public static void main(String[] args) throws IOException
	{
		int n = in.nextInt();
		int r = (int)Math.sqrt(n);
		sop(2 * r + 2 * (n / r + (n % r != 0 ? 1 : 0)));
	}

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader in = new FastReader();

    public static void sop(Object o)
    {
    	System.out.print(o);
    }
}

import java.util.Scanner;

public class JavaApplication2 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = (int) Math.pow(n, 0.5);
        int ans;
        if (k * k == n)
            System.out.println(4 * k);
        else
        {
            k++;
            int r = n / k;
            ans = (k + r) * 2;
            if (n % k > 0)
                ans += 2;
            System.out.println(ans);
        }
    }
}

import java.util.Scanner;
public class LazySecurity{
	public static void main(String[] args){
		Scanner kbd = new Scanner(System.in);
		int n = kbd.nextInt();
		System.out.println(2*(int)(Math.ceil(2*Math.sqrt(n))));

	}
}

/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int sq = (int) Math.sqrt(n);

		int ans =  sq * 4;
		n -= sq*sq;

		if(n != 0) {
			if(n <= sq) {
				ans += 2;
			} else {
				ans += 4;
			}
		}

		System.out.println(ans);
	}
}

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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    void start() {
        int n = readInt();
        int w = 1;
        while (w*w < n) w++;
        int p = 0;
        int h = n / w;
        if (n % w == 0) {
            p = 2*(w + h);
        } else {
            p = 2*w + 2*h + 2;
        }
        System.out.println(p);
    }

    public static void main(String[] args) {
        new Test().start();
    }
}

//package practice;

import java.util.Scanner;

public class ProblemBSep16 {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();

        int firstNum = (int)(Math.sqrt(num));
        int secondNum = num/firstNum;
        if(num - firstNum*secondNum== 0)

        {
            System.out.println(2*(firstNum+secondNum));
        }
        else{
            System.out.println(2*(firstNum+secondNum) + 2);
        }
    }

}

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

public class B {
	public static void main(String[] args) {
		try {
			InputStreamReader converter = new InputStreamReader(System.in);
			BufferedReader in = new BufferedReader(converter);
			int N = Integer.parseInt(in.readLine());
			int square = (int) Math.sqrt(N);
			if (square * square == N) {
				System.out.println(square * 4);
			} else if (square * (square + 1) >= N) {
				System.out.println(2 * (square + square + 1));
			} else {
				System.out.println((square + 1) * 4);
			}
		} catch (Exception e) {
			System.out.println("Error! Exception: " + e);
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;

		public class Solution123 implements Runnable
		{
			static final int MAX = 1000000007;
			static class InputReader
			{
				private InputStream stream;
				private byte[] buf = new byte[1024];
				private int curChar;
				private int numChars;
				private SpaceCharFilter filter;
				private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

				public InputReader(InputStream stream)
				{
					this.stream = stream;
				}

				public int read()
				{
					if (numChars==-1)
						throw new InputMismatchException();

					if (curChar >= numChars)
					{
						curChar = 0;
						try
						{
							numChars = stream.read(buf);
						}
						catch (IOException e)
						{
							throw new InputMismatchException();
						}

						if(numChars <= 0)
							return -1;
					}
					return buf[curChar++];
				}

				public String nextLine()
				{
					String str = "";
		            try
		            {
		                str = br.readLine();
		            }
		            catch (IOException e)
		            {
		                e.printStackTrace();
		            }
		            return str;
				}
				public int nextInt()
				{
					int c = read();

					while(isSpaceChar(c))
						c = read();

					int sgn = 1;

					if (c == '-')
					{
						sgn = -1;
						c = read();
					}

					int res = 0;
					do
					{
						if(c<'0'||c>'9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					while (!isSpaceChar(c));

					return res * sgn;
				}

				public long nextLong()
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					int sgn = 1;
					if (c == '-')
					{
						sgn = -1;
						c = read();
					}
					long res = 0;

					do
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					while (!isSpaceChar(c));
						return res * sgn;
				}

				public double nextDouble()
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					int sgn = 1;
					if (c == '-')
					{
						sgn = -1;
						c = read();
					}
					double res = 0;
					while (!isSpaceChar(c) && c != '.')
					{
						if (c == 'e' || c == 'E')
							return res * Math.pow(10, nextInt());
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					if (c == '.')
					{
						c = read();
						double m = 1;
						while (!isSpaceChar(c))
						{
							if (c == 'e' || c == 'E')
								return res * Math.pow(10, nextInt());
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							m /= 10;
							res += (c - '0') * m;
							c = read();
						}
					}
					return res * sgn;
				}

				public String readString()
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					StringBuilder res = new StringBuilder();
					do
					{
						res.appendCodePoint(c);
						c = read();
					}
					while (!isSpaceChar(c));

					return res.toString();
				}

				public boolean isSpaceChar(int c)
				{
					if (filter != null)
						return filter.isSpaceChar(c);
					return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				}

				public String next()
				{
					return readString();
				}

				public interface SpaceCharFilter
				{
					public boolean isSpaceChar(int ch);
				}
			}

			public static void main(String args[]) throws Exception
			{
				new Thread(null, new Solution123(),"Solution123",1<<26).start();
			}
			static long[] ans = new long[1000001];
			static int[] temp;
			static long[][] count = new long[1000001][9];
			static int[] freq;
			static HashSet<Integer> pw2 = new HashSet();
			static ArrayList<Integer> ar[] = new ArrayList[9];
			public void run()

			{
				InputReader sc= new InputReader(System.in);
				PrintWriter w= new PrintWriter(System.out);
				int n = sc.nextInt();
				int z = (int)Math.sqrt(n);
				if(z * z == n){
					w.println(4 * z);
				}else{
					w.println((int)((z + 1) + Math.ceil((n*1.0/(z + 1)))) * 2);
				}
				w.close();
			}
			static class Pair{
				int a;
				int b;
				int c;
				Pair(int a,int b,int c){
					this.a = a;
					this.b = b;
					this.c = c;
				}
			}
		}

import java.util.Scanner;
public class Sample {

	public static void main(String[] args) {

		Scanner kbd = new Scanner(System.in);
		String input = kbd.nextLine();
		int num = Integer.parseInt(input);

		double sqroot = Math.sqrt(num);
		double deci = sqroot - Math.floor(sqroot);
		deci = deci * 10;

		if (deci < 5 && deci != 0) {

			System.out.println((int)(Math.ceil(sqroot) * 4) - 2);

		} else {

			System.out.println((int)Math.ceil(sqroot) * 4);

		}

	}

}

import java.util.*;
public class LazyGuard {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double N;
        N = scan.nextInt();

        int root = (int)Math.sqrt(N);
        if(root * root == (int)N) {
            System.out.print(4 * root);
        } else {
            int lower = (int)root;
            int upper = lower + 1;
            int answer = 4 * lower;
            lower *= lower;
            upper *= upper;

            int middle = (upper - lower)/2 + lower;

            if((int)N <= middle) {
                System.out.print(answer + 2);
            } else {
                System.out.print(answer + 4);
            }
        }
    }
}

import java.util.Scanner;

public class Codechef {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt(), n1 = 0, n2 = 0, n3 = 0, x1 = 0, x2 = 0;
        int x = (int) Math.sqrt(n);
        if (x * x == n) {
            System.out.println(x * 4);
        } else {
            x2 = x * 4;//12
            x1 = x * x;//9
            n1 = n - x1;//2
            x2 = x2 - n1;
            if (n1 <= x) {
                System.out.println(x2 + n1 + 2);
            } else {
                n2 = n1 / 2;
                n3 = n1 - n2;
                n2 = n2 + 2;
                n3 = n3 + 2;
                System.out.println(x2 + n2 + n3);
            }

        }
    }

}

//package Ladder_B;
/**
 * Created by Eesaa on 9/16/2017.
 */

        import java.util.*;

public class B_859 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        System.out.println(2*(int)(Math.ceil(2*Math.sqrt(n))));
    }
}

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

      Scanner in=new Scanner(System.in);
      int n=in.nextInt();
//      double w1=Math.sqrt(n);

      double w= Math.ceil(Math.sqrt(n));
      double h=Math.ceil(n/w);
      int res=(int)(h+w)*2;
//       double h1=(n/w1);

        System.out.println(res);

    }

}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=(int)Math.floor(Math.sqrt(n));
		int p=n/k;
		int r=n-p*k;
		if(r==0){
		    System.out.println(2*k+2*p);
		}
		else{
		    System.out.println(k+2*p+2+k);
		}
	}
}

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

public class LazySecurityGuard4 {

    public static void main(String... args) {
        InputReader reader = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out, false);

        out.println(solve(reader.nextInt()));

        out.flush();
        out.close();
    }

    public static int solve(int N) {
        // go through every possible side length, 1 to 10^3
        // since 10^3 * 10^3 is 10^6 which is the max value of N
        for (int sideLength = 1; sideLength <= 10000; sideLength++) {
            // something to note is that there are two possible perimeter scenarios
            // before that though, note the perimeter of any partial rectangle is
            // the perimeter of the next full rectangle
            // this then leads us to the two scenarios from before:
            // whether or not the next full rectangle is a square

            // this is for if the next rectangle is not a square
            if (sideLength * sideLength >= N) return 4 * sideLength;
            // this is for if the next rectangle is a square
            else if (sideLength * (sideLength + 1) >= N) return 4 * sideLength + 2;
        }
        return -1; // this should never occur
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

}

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

public class LazySecurityGuard7 {

    public static void main(String... args) {
        InputReader reader = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out, false);

        out.println(solve(reader.nextInt()));

        out.flush();
        out.close();
    }

    public static int solveOld(int N) {
        // find the nearest rectangle, rounded down in size
        int length = (int) Math.sqrt(N);
        int width = N / length;

        // determine whether or not there are more blocks
        // N % width gives the number of additional blocks
        // to add to the rectangle, if it's greater than 0 blocks,
        // add 2 (1 for each side of the new block section added)
        if (N % width != 0) return 2 * (width + length) + 2;
        else return 2 * (width + length);
    }

    // the above method should be able to be replaced with the below
    public static int solve(int N) {
        // find the nearest rectangle with a larger area,
        // the perimeter will be the same
        int length = (int) Math.ceil(Math.sqrt(N));
        int width = (N + length - 1) / length;

        return 2 * (width + length);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

}

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

public class LazySecurityGuard {

    public static void main(String... args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out, false);

        int n = Integer.parseInt(read.readLine());
        int core = (int) Math.sqrt(n);
        int remaining = n - (core * core);
        int adjust = 0;

        if (remaining > 0) {
            if (remaining > core) adjust += 4;
            else adjust += 2;
        }

        out.println((core * 4) + adjust);

        out.flush();
        out.close();
        read.close();
    }

}

import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;

public class Problem2 {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double n=sc.nextDouble();
		double w=Math.ceil(Math.sqrt(n));
		double h=Math.ceil(n/w);

		DecimalFormat q=new DecimalFormat("0");

		System.out.println(q.format(2*(w+h)));

	}
}

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

public class Main {
   public static void main(String[] args) throws IOException {
      BufferedReader var = new BufferedReader(new InputStreamReader(System.in));
      int n = Integer.parseInt(var.readLine());
      int x = 0;
      int temp = (int) Math.sqrt(n);
      if (Math.pow(temp, 2) == n) {
         System.out.println((int) Math.sqrt(n) * 4);
      }
      else if( n == 2){
         System.out.println(6);
      }
      else {
         int cnt = 1;
         while (true) {
            if (Math.pow(cnt, 2) <= n)
               cnt++;
            else {
               x = cnt;
               break;
            }
         }
         if (Math.pow(x, 2) - n > Math.sqrt(n)) {
            int s = 0;
            s = x + (int) Math.sqrt(n) + (x - 2) + ((((int) (Math.pow(x, 2) - x) - n) + 1)) + (x - ((((int) (Math.pow(x, 2) - x) - n) + 1)) + 1);
            System.out.println(s);
         } else {
            System.out.println((x * 2) + (int) Math.sqrt(n) + ((int) (Math.pow(x, 2) - n) + 1) + (x - ((int) Math.pow(x, 2) - n)));
         }
      }
   }
}

import org.omg.CORBA.INTERNAL;

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

public class LazySecurityGuard3 {

    public static void main(String... args) {
        InputReader reader = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out, false);

        out.println(solve(reader.nextInt()));

        out.flush();
        out.close();
    }

    public static int solve(int N) {
        // this is the smallest perimeter of all the possible rectangle configurations
        int smallestPerimeter = Integer.MAX_VALUE;

        // go through all the possible rectangle configurations
        // note that the length can be any value from 1 to N
        // since the width will vary to ensure there are always N blocks
        for (int length = 1; length <= N; length++) {
            // this is a shortcut to do ciel(N / length) for integers,
            // used since N = length * width therefore width = N / length,
            // rounded up since width needs to be an integer and we want
            // the next (larger) rectangle, not a smaller rectangle
            int width = (N + length - 1) / length;

            // see if our smallest perimeter or the perimeter of this rectangle is smaller
            smallestPerimeter = Math.min(smallestPerimeter, 2 * (length + width));
        }

        return smallestPerimeter;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

}

import java.util.Scanner;

public class PrimPrim
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int area = in.nextInt();
		int sqrt = (int)Math.sqrt((double)area);

		int base = sqrt * 4;
		int rem = area - sqrt* sqrt;
		if(rem == 0)
		{
			base+=0;
		}
		else if(rem > sqrt)
		{
			base+=4;
		}
		else
		{
			base+=2;
		}

		System.out.println(base);
	}
}

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

public class LazySecurityGuard5 {

    public static void main(String... args) {
        InputReader reader = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out, false);

        out.println(solve(reader.nextInt()));

        out.flush();
        out.close();
    }

    public static int solve(int N) {
        // this approach starting with a 1x1 rectangle (square)
        // and constantly checks if area (number of blocks) of the
        // rectangle is larger than the number of blocks required (N)
        // if not, extend one side of the rectangle 1 block and check
        // if still not, extend the rectangle one block in the other
        // direction to make it a square and repeat till the area
        // is greater than N, the final length and width values of
        // the rectangle can then be used to find the perimeter

        // start with a 1x1 square
        int length = 1;
        int width = 1;

        // while the area (number of blocks) is less
        // than the needed number of blocks
        while ((length * width) < N) {
            length++; // this extends our initial square to a larger rectangle

            // if the rectangle doesn't contain enough blocks,
            // convert our rectangle to a larger square
            if ((length * width) < N) width++;
        }

        // the perimeter
        return 2 * (length + width);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class cfs{
    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    private static long mod = 1000000000 + 7;
    private static long mod1 = 1000000000 + 9;
    private static int MAX=1000001;
    private static int block;
    //private static int[] dfs1;
    private static int[] tin;
    private static int[] tout;
    private static int level=0;
    //private static Node[] nodes1;
    //private static ArrayList<Integer>[] list;
    private static void soln(){
        int n=nextInt();
        int ans=0;int c=0;
        for(int i=1;i<=1001;i++)
        {
        	if(n<(i*i))
        	{
        		ans=i-1;
        		c=i-1;
        		break;
        	}
        }
        //pw.println(c);
        int rem=n-(ans*ans);
        ans=ans*4;
        int y=0;
        while(y<rem)
        {
        	ans+=2;
        	rem-=c;
        }
        pw.print(ans);
    }
private static class Pair implements Comparable<Pair>{
    int v,i;
    public Pair(int a,int b){
        v=a;
        i=b;
    }
    @Override
    public int compareTo(Pair arg0) {
        return this.v-arg0.v;
    }
}
public static class Merge {
    public void sort(int inputArr[]) {
        int length = inputArr.length;
        doMergeSort(inputArr,0, length - 1);
    }
    private void doMergeSort(int[] arr,int lowerIndex, int higherIndex) {
        if (lowerIndex < higherIndex) {
            int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
            doMergeSort(arr,lowerIndex, middle);
            doMergeSort(arr,middle + 1, higherIndex);
            mergeParts(arr,lowerIndex, middle, higherIndex);
        }
    }
    private void mergeParts(int[]array,int lowerIndex, int middle, int higherIndex) {
        int[] temp=new int[higherIndex-lowerIndex+1];
        for (int i = lowerIndex; i <= higherIndex; i++) {
            temp[i-lowerIndex] = array[i];
        }
        int i = lowerIndex;
        int j = middle + 1;
        int k = lowerIndex;
        while (i <= middle && j <= higherIndex) {
            if (temp[i-lowerIndex] < temp[j-lowerIndex]) {
                array[k] = temp[i-lowerIndex];
                i++;
            } else {
                array[k] = temp[j-lowerIndex];
                j++;
                //cnt+=(middle+1-i);
            }
            k++;
        }
        while (i <= middle) {
            array[k] = temp[i-lowerIndex];
            k++;
            i++;
        }
        while(j<=higherIndex){
            array[k]=temp[j-lowerIndex];
            k++;
            j++;
        }
        /*pw.println(lowerIndex+" "+higherIndex);
        for(int m=lowerIndex;m<=higherIndex;m++)
            pw.print(array[m]+" ");
        pw.println();*/
    }
}
    public static class Segment {
        private int[] tree;
        private int size;
        private int n;
        private class node{
            private int a;
            private int b;
            private int c;
            public node(int x,int y,int z){
                a=x;
                b=y;
                c=z;
            }
        }
        public Segment(int n){
            //this.base=arr;
            int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
            size = 2 * (int) Math.pow(2, x) - 1;
            tree=new int[size];
            this.n=n;
            //build(0,0,n-1);
        }
        public int query(int l,int r){
            return queryUtil(l,r,0,0,n-1);
        }
        private int queryUtil(int x,int y,int id,int l,int r){
            if(l>y || x>r)
                return 0;
            if(x <= l && r<=y)
                return tree[id];
            int mid=l+(r-l)/2;
            return queryUtil(x,y,2*id+1,l,mid)+queryUtil(x,y,2*id+2,mid+1,r);
        }
        public void update(int x,int colour,int id,int l,int r){
            //System.out.println(l+" "+r+" "+x);
            if(x>r || x<l)
                return;
            if(l==r){
                tree[id]+=colour;
                return;
            }
            int mid=l+(r-l)/2;
            update(x,colour,2*id+1,l,mid);
            update(x,colour,2*id+2,mid+1,r);
            tree[id]=tree[2*id+1]+tree[2*id+2];
        }
    }
    private static class DSU{
        int[] parent;
        int[] rank;
        int cnt;
        public DSU(int n){
            parent=new int[n];
            rank=new int[n];
            for(int i=0;i<n;i++){
                parent[i]=i;
                rank[i]=1;
            }
            cnt=n;
        }
        int find(int i){
            while(parent[i] !=i){
                parent[i]=parent[parent[i]];
                i=parent[i];
            }
            return i;
        }
        int Union(int x, int y){
            int xset = find(x);
            int yset = find(y);
            if(xset!=yset)
                cnt--;
            if(rank[xset]<rank[yset]){
                parent[xset] = yset;
                rank[yset]+=rank[xset];
                rank[xset]=0;
                return yset;
            }else{
                parent[yset]=xset;
                rank[xset]+=rank[yset];
                rank[yset]=0;
                return xset;
            }
        }
    }
    static void multiply(long[][] a, long[][] b,long m){
        int n=a.length;
        long[][] mul=new long[n][n];
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                mul[i][j] = 0;
                for (int k = 0; k < n; k++)
                    mul[i][j] = (mul[i][j]+(a[i][k]*b[k][j])%m)%m;
            }
        }
        for (int i=0; i<n; i++)
            for (int j=0; j<n; j++)
                a[i][j] =mul[i][j];
    }
    private static long pow(long a, long b, long c) {
        if (b == 0)
            return 1;
        long p = pow(a, b / 2, c);
        p = (p * p) % c;
        return (b % 2 == 0) ? p : (a * p) % c;
    }

    private static class Mo implements Comparable<Mo>{
        int l;
        int r;
        int i;
        public Mo(int a,int b,int ind) {
            l=a;r=b;i=ind;
        }
        @Override
        public int compareTo(Mo arg0) {
            int b1=this.l/block;
            int b2=arg0.l/block;
            return (b1!=b2)?(b1-b2):(this.r-arg0.r);
        }
    }

    private static long gcd(long n, long l) {
        if (l == 0)
            return n;
        return gcd(l, n % l);
    }

    private static long max(long a, long b) {
        if (a > b)
            return a;
        return b;
    }

    private static long min(long a, long b) {
        if (a < b)
            return a;
        return b;
    }

    public static void main(String[] args) throws Exception {
        new Thread(null,new Runnable(){
            @Override
            public void run() {
                /*try {
                    InputReader(new FileInputStream("C:\\Users\\hardik\\Desktop\\C-small-1-attempt1.in"));
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }*/
                InputReader(System.in);
                pw = new PrintWriter(System.out);
                /*try {
                    pw=new PrintWriter(new FileOutputStream("C:\\Users\\hardik\\Desktop\\out.txt"));
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }*/
                soln();
                pw.close();
            }
        },"1",1<<26).start();
    }

    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

    private static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private static boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    private static int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    private static int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private static String nextLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    private static int[] nextIntArray(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    private static long[] nextLongArray(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextLong();
        }
        return arr;
    }

    private static void pArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static void pArray(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }
    private static char nextChar() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        char c1=(char)c;
        while(!isSpaceChar(c))
            c=read();
        return c1;
    }
    private interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.util.*;
public class newbar
{
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        int n,size=0,i,j,lim,c=0,p=0,k=0;
        n=in.nextInt();
        for (i=1;i<=n;i++)
        {
            if (i*i>=n)
            {
                size=i;
                break;
            }
        }
        size+=2;
        int[][] a=new int[size][size];
        int m=n;
        for (i=0;i<size;i++)
        {
            for (j = 0; j < size; j++)
            {
                if (i == 0 || j == 0 || i == size - 1 || j == size - 1)
                {
                    a[i][j] = 0;
                } else
                {
                    if (m > 0)
                    {
                        a[i][j] = 1;
                        m--;
                    } else
                        a[i][j] = 0;
                }
            }
        }
        /*for (i=0;i<size;i++)
        {
            for (j=0;j<size;j++)
                System.out.print(a[i][j]+" ");
            System.out.println();
        }*/
        for (i=1;i<size-1;i++)
        {
            for (j=1;j<size-1;j++)
            {
                if (a[i][j]==1)
                {
                    k=0;
                    if (a[i][j-1]==0) k++;
                    if (a[i-1][j]==0) k++;
                    if (a[i][j+1]==0) k++;
                    if (a[i+1][j]==0) k++;
                    p=p+k;
                    //System.out.print(k+" ");
                }
            }
        }
        System.out.println(p);
    }
}

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

import static java.lang.StrictMath.sqrt;

public class LazyGuard {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int tiles = Integer.parseInt(reader.readLine());
        int sqrt = (int) sqrt(tiles);
        int sq = sqrt * sqrt;
        int left = tiles - sq;
        int perimeter = sqrt * 4;
        if (left == 0) {
            System.out.print(perimeter);
        } else {
            if (left > sqrt) {
                perimeter += 2;
                //left -= sqrt;
            }
            perimeter += 2;
            //perimeter += left;
            System.out.print(perimeter);
        }

    }
}

import java.util.Scanner;

public class Codeforces859B {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.close();

		for(long len = 4;;len+=2){
			long a = len/4;
			long b = len/2-a;
			if(a*b >= n){
				System.out.println(len);
				return;
			}
		}

	}

}

import java.util.Scanner;

public class LazySecurityGuard
{

    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int cityBlocks = input.nextInt();
        int squareLength = (int)(Math.sqrt(cityBlocks));
        int blocksInSquare = (int)(Math.pow(squareLength, 2));
        input.close();

        // adding extra sides for irregular shapes
        int extraBlocks = cityBlocks - blocksInSquare;

        if (extraBlocks == 0) {
            System.out.println(squareLength * 4);
        }
        else if (squareLength - extraBlocks >= 0) {
            System.out.println((squareLength * 4) + 2);
        }
        // if extra blocks wrap around to both width and length; any more would cause a bigger perfect square
        else if (squareLength - extraBlocks < 0) {
            System.out.println((squareLength * 4) + 4);
        }
    }

}

import java.util.*;

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

        int l;
        if(n % b == 0)
        l = n/b;

        else
        l = n/b + 1;

        System.out.println(2 * (l + b));
    }
}

import java.util.*;
public class LazySecurityGuard {
    public static void main(String args[]){
        Scanner sc= new Scanner(System.in);
        double n=sc.nextDouble();
        int x=(int)Math.floor(Math.sqrt(n));
        int y=(int)Math.ceil(n/x);
        int ans=2*(x+y);
        System.out.println(ans);
    }
}

import java.util.Scanner;

public class lazy_security {
    private int a;
    private int b1,b2;

    public static void main(String[] args) {
    lazy_security security =new lazy_security();
        security.setA();
        System.out.println(security.check_up());
    }
    public void setA()
    {
        Scanner sc =new Scanner(System.in);
        a=sc.nextInt();

    }
    public int check_up()
    {
        b1=(int)Math.sqrt(a);
b2=b1;
a-=b1*b1;
b2+=a/b1;
a%=b1;

return a==0 ?((b1+b2)*2):((b1+b2)*2+2);

    }
}

import java.util.*;

public class acm {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long i=1;
		long ans = 0;

		while(i*i<=n){

			i++;
		}
		--i;
		ans= 4*i + ((n-i*i)/i)*2 ;
		if((n-i*i)%i !=0)ans+=2;
		System.out.println(ans);

	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int N = (int) Math.ceil(2*Math.sqrt(n));
        int result = 2*(N);
        System.out.println(result);

    }
}

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

/*
Good, better, best. Never let it rest. 'Til your good is better and your better is best.
 */

public class Main {

    // SOLVER
    static void solve() {
        // INPUT OUTPUT
        InputReader in = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        int testCase = 1;
        StringBuilder result = new StringBuilder();
        while (--testCase >= 0)
        /**************************************************************************/
        {
            // SOLVE
            int noOfBlocks = in.nextInt();
            int minPerimeter = 0;
            double height;
            double width;

            height = Math.ceil(Math.sqrt(noOfBlocks));
            width = Math.ceil((double)noOfBlocks / height);
            minPerimeter = 2 * (int)(height + width);

            result.append(minPerimeter);
            /*****************************************/
        }
        pw.println(result.toString().trim());
        // *************************************
        {
            pw.close();
        }
    }

    /**************************************************************************
     *************************************************************************/
    // DRIVER CODE
    public static void main(String[] args) {
        solve();
    }

    // FAST INPUT
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

        public String readString() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}

import java.util.Scanner;

public class LazyGuard {
    public static void main(String[] args) {
        Scanner in=new Scanner (System.in);
        int N=in.nextInt();
        int ans= (int) (2*Math.ceil (2*Math.sqrt (N)));
        System.out.println (ans);
    }
}

import java.io.*;
import java.util.*;
public class Blockwalk
{
	public static void main(String args[])
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int i = (int)Math.ceil(Math.sqrt(n));
		int p = 4*i - 2*((i*i-n)/i);
		System.out.println(p);

	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class solution {
    public static void merge(long arr[], int l, int m, int r) {
        int n1 = m - l + 1;
        int n2 = r - m;
        long L[] = new long[n1];
        long R[] = new long[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];

        int i = 0, j = 0;

        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            } else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    public static void sort(long arr[], int l, int r) {
        if (l < r) {
            int m = (l + r) / 2;

            sort(arr, l, m);
            sort(arr, m + 1, r);

            merge(arr, l, m, r);
        }
    }

    public static boolean check(int n) {
        String s = "";
        s += n;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != '4' && s.charAt(i) != '7') {
                return false;
            }
        }
        return true;
    }

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

    public static long findTrailingZeros(long n) {
        // Initialize result
        long count = 0;

        // Keep dividing n by powers
        // of 5 and update count
        for (long i = 5; n / i >= 1; i *= 5)
            count += n / i;

        return count;
    }

    public static int ceilSearch(long arr[], int low, int high, long x) {
        int mid;

        if (x <= arr[low])
            return low;
        if (x > arr[high])
            return -1;

        mid = (low + high) / 2;

        if (arr[mid] == x)
            return mid;

        else if (arr[mid] < x) {
            if (mid + 1 <= high && x <= arr[mid + 1])
                return mid + 1;
            else
                return ceilSearch(arr, mid + 1, high, x);
        } else {
            if (mid - 1 >= low && x > arr[mid - 1])
                return mid;
            else
                return ceilSearch(arr, low, mid - 1, x);
        }
    }

    public static double dis(double x, double x1, double y, double y1) {
        double dis = Math.sqrt(Math.pow((x - x1), 2) + Math.pow((y - y1), 2));
        return dis;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int u = (int)Math.sqrt(n);
        int v = n/u;
        int ans = 2*(u+v);
        if(n%u!=0){
            ans+=2;
        }
        System.out.println(ans);
    }
}

import java.io.*;
import java.util.*;
public class LazySecurityGuard
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int sr=(int)(Math.sqrt(n));
        int left=n-(sr*sr);
        int count=0,result=0;
        while(left>=sr)
        {
            left=left-sr;
            count++;
        }
        result=result+sr+((sr+count)*2)+(sr-left);
        if(left==1)
            result=result+3;
        else if(left>1)
            result=result+(left-2)+(2*2);
        System.out.println(result);
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int ans=Integer.MAX_VALUE;
	    for(int i=1;i<=n;i++){
	        int cur=2*(i+n/i)+(n%i==0?0:2);
	        if(cur<ans){
	            ans=cur;
	        }
	    }
	    System.out.println(ans);
	}
}

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

public class A
{
	public static void main (String[] args)
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		System.out.print(2*(int)Math.ceil(2*Math.sqrt(n)));
	}
}

import java.util.Scanner;

public class LazySecurityGuard {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int blocks = scan.nextInt();
        int squareLength = (int) Math.sqrt(blocks);
        int sqaureBlocks = squareLength * squareLength;
        int remainder = blocks - sqaureBlocks;
        int perimeter = squareLength * 4;

        int side1Blocks, side2Blocks;

        if (remainder < squareLength) {
            side1Blocks = remainder;
            side2Blocks = 0;
        } else {
            side1Blocks = squareLength;
            side2Blocks = remainder - squareLength;
        }

        if (side1Blocks > 0) {
            perimeter += 2;
        }

        if (side2Blocks > 0) {
            perimeter += 2;
        }

        System.out.println(perimeter);
        scan.close();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int H = 1;
            while (H * H < N) H++;
            int W = (N + H - 1) / H;
            out.println(2 * (H + W));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
        new Main();
    }

	int n;

	public Main() throws Exception{
		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new FileReader("input"));

		n = sc.nextInt();

		int k = 0;

		for (int i=0;true;i++){

			if (i * i >= n){
				k = i;
				break;
			}

		}

		if (k * (k-1) >= n){
			System.out.println(  2 * k + 2 * (k-1));
		} else {
			System.out.println(  4 * k);
		}

        sc.close();
	}

	void printArr(int[] arr){
		System.out.println();
		for(int i=0;i<arr.length;i++){
			System.out.print(arr[i] + " ");
		}
		System.out.println();

	}

}

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner (System.in);

		int n = sc.nextInt();
		if (n==1)
		System.out.println(4);
		else
		{
		  int sq = 0;
		for (int i =2;i<=n;i++)
		{
		    if(i*i>=n)
		    {
		        sq = i;
		        break;
		    }
		}

		int ans = sq*2 + 2*(int)Math.ceil((double)n/sq);
		System.out.println(ans);

		}

		sc.close();
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int res = Integer.MAX_VALUE;
            for (int i = 1; i <= (n + 1) / 2; ++i) {
                for (int j = 1; ; ++j) {
                    if (i * j >= n) {
                        res = Math.min(res, i * 2 + j * 2);
                        break;
                    }
                }
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

import java.util.Scanner;
public class LazySecurityGuard{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double squareRoot = Math.sqrt(scan.nextInt());
		System.out.println(2*((int)Math.ceil(2*squareRoot)));
	}
}

import java.util.Scanner;
public class Sample {

	public static void main(String[] args) {

		Scanner kbd = new Scanner(System.in);
		String input = kbd.nextLine();
		int num = Integer.parseInt(input);

		double sqroot = Math.sqrt(num);
		double deci = sqroot - Math.floor(sqroot);
		deci = deci * 10;

		if (deci < 5 && deci != 0) {

			System.out.println((int)(Math.ceil(sqroot) * 4) - 2);

		} else {

			System.out.println((int)Math.ceil(sqroot) * 4);

		}

	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author pandusonu
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int big = -1;
            for (int i = 1; i < 1001; i++) {
                if (i * i >= n) {
                    big = i;
                    break;
                }
            }
            if (big * big == n) {
                out.println(big * 4);
            } else {
                big--;
                int x = n - big * big;
                if (x <= big) {
                    out.println(2 * (big + big + 1));
                } else out.println((big + 1) * 4);
            }
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            try {
                if (curChar >= numChars) {
                    curChar = 0;
                    numChars = stream.read(buf);
                    if (numChars <= 0)
                        return -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return buf[curChar++];
        }

        public int readInt() {
            return (int) readLong();
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1) throw new RuntimeException();
            }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += (c - '0');
                c = read();
            } while (!isSpaceChar(c));
            return negative ? (-res) : (res);
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//System.out.println("hhhkkjhkj");
		int N =0, helper = 0, ans = 0;
		double d = 0;

		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {

			N = Integer.parseInt(sc.nextLine());

			d = Math.sqrt(N);

			helper=(int) Math.round(d);

			if(helper > d  || helper == d )
				ans = helper * 4;
			else
			ans = helper * 4 + 2;

			System.out.println(ans);
		}

	}

}

import java.io.BufferedInputStream;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Scanner;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {
	// public static BigDecimal sqrt(BigDecimal a, BigDecimal _2, int precision) {
	// // TODO Auto-generated method stub
	// MathContext mc = new MathContext(precision, RoundingMode.HALF_UP); //
	// 某个操作使用的数字个数；结果舍入到此精度
	// if (a.compareTo(BigDecimal.ZERO) == 0)
	// return BigDecimal.ZERO;
	//
	// if (a.compareTo(BigDecimal.ONE) == 0)
	// return BigDecimal.ONE;
	//
	// BigDecimal x = a;
	// int cnt = 0;
	// while (cnt < 100) {
	// x = (x.add(a.divide(x, mc))).divide(_2, mc);
	// cnt++;
	// }
	// return x;
	// }

	// public static ScriptEngine ENGINE = new
	// ScriptEngineManager().getEngineByName("javascript");
	public static ScriptEngine ENGINE = new ScriptEngineManager().getEngineByName("nashorn");

	public static Scanner cin = new Scanner(new BufferedInputStream(System.in));
	// public static PrintStream cout = new PrintStream(new
	// BufferedOutputStream(System.out), false);

	public static void main(String[] args) {

		StringBuilder s = new StringBuilder();
		s.append("var n = Java.type('Main').cin.nextInt();");
		s.append("var mina = (1 << 30);");
		s.append("for (var i = 1; i <= n; i++) {");
		s.append("	var j = n / i;");
		s.append("	if (n % i) {");
		s.append("		j++;");
		s.append("	}");
		s.append("	var nowa=((i+j)<<1);");
		s.append("	mina>nowa?mina=nowa:0;");
		s.append("}");
		s.append("print(mina);");

		// s.append("Java.type(\"Main\").cout.println(ansa);");
		try {
			ENGINE.eval(s.toString());
		} catch (ScriptException e) {
			e.printStackTrace();
		}
		cin.close();
		// cout.close();

	}

}

import java.util.Scanner;
import java.util.Arrays;
public class Ishu
{
	public static void main(String []args)
	{
	Scanner scan=new Scanner(System.in);
	int n;
	n=scan.nextInt();
	int sq=(int)Math.sqrt(n);
	int rem=n-sq*sq;
	int ans=4*sq;
	while(rem>0)
		{
		ans+=2;
		rem-=sq;
		}
	System.out.println(ans);
	}
}

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

public class CodeForces
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = input.nextInt();
		int d = (int) Math.sqrt(n);
		int r = n - d * d;
		if (r == 0)
		{
			System.out.println(4 * d);
		} else if (r <= d)
		{
			System.out.println(4 * d + 2);
		} else
		{
			System.out.println(4 * d + 4);
		}
	}
}

import java.util.Scanner;

public class LazyGuard
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int blocks = scan.nextInt();
		if(blocks == 1)
		{
			System.out.println(4);
		}
		else if(blocks == 2)
		{
			System.out.println(6);
		}
		else if(blocks == 3)
		{
			System.out.println(8);
		}
		else if(blocks == 4)
		{
			System.out.println(8);
		}
		else
		{
			int square = 2;
			while(square * square <= blocks)
			{
				square++;
			}
			square--;
			int total = square * 4;
			blocks = blocks - square * square;
			if(blocks == 0)
			{
				System.out.println(total);
			}
			else
			{
				int extra = blocks / square;
				if(blocks % square != 0)
				{
					extra++;
				}
				total = total + extra * 2;
				System.out.println(total);
			}

		}

		scan.close();
	}
}

import java.util.Scanner;

public class test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);

		String input;
		input = scanner.nextLine();

		int n = Integer.parseInt(input);

		int i, j, ans;
		if (n == 1)
			System.out.println(4);
		else if (n == 2)
			System.out.println(6);
		else if (n == 3)
			System.out.println(8);
		else{
			i = 1;
			while (i * i <= n)
				i++;

			i--;
			if (n == i * i)
				System.out.println(4 * i);
			else{
				j = n / i;
				ans = 2 * j + 2 * i;
				if (n % i != 0)
					ans += 2;
				System.out.println(ans);
			}
		}

		scanner.close();
	}

}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Memsql2 {
	static MyScanner in = new MyScanner();
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

	public static void main(String[] args) {

		int n = in.nextInt();
		long sq = 0;
		for (long i = 0; i < n; i++) {
			if (i * i <= n) {
				sq = i;
			}
		}
		if (n == 2) {
			out.println(6);
		} else if (sq * sq == n) {
			out.println(sq * 4);
		} else if (sq * sq + sq >= n) {
			out.print(4 * sq + 2);
		} else {
			out.println(4 * sq + 4);
		}
		/*
		 * Dont delete
		 */
		out.close();
		/*
		 *
		 */
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.util.Scanner;

public class Problem {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int N = scanner.nextInt();
        if (N == 1) {
            System.out.println(4);
            return;
        }
        final long K = Math.round(Math.sqrt(N));
        int perimeter = 0;
        int i = 0;
        perimeter += K + 2;
        i += K;
        while (i < N) {
            if (N - i <= K) {
                perimeter += 2 + K;
                i += N - i;
            } else {
                perimeter += 2;
                i += K;
            }
        }
        System.out.println(perimeter);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (PloadyFree@gmail.com)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int len = (int) Math.sqrt(n);
            int ans = len * 2 + (n / len) * 2;
            if (n % len > 0) {
                ans += 2;
            }
            out.print(ans);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void print(int i) {
            writer.print(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        double rest = sqrt((double) n);
        if (rest - (int) (rest) == 0) out.println((int) rest * 4);
        else {
            int sq = (int) rest * (int) rest;
            if (n - sq <= (int) rest) out.println((int) rest * 4 + 2);
            else out.println((int) rest * 4 + 4);
        }
    }
}

import java.util.Scanner;

public class Security {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long a=0,b=0;
       long p=(long)(Math.sqrt(n));
        a=p;
        b=(long) Math.ceil((double)n/p);
           System.out.println(2*(a+b));
    }
}

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

public class LazySG {
	private static Scanner scanner = new Scanner(System.in);

	public static int Area(int input) {
		int tempInput = input;
		int area = 4;
		int determine = 2;
		while(determine < tempInput) {
			area += 4;
			tempInput -= determine;
			determine += 2;

		}

		// System.out.println("area : " + area);
		// System.out.println("tempInput : " + tempInput);
		// System.out.println("determine : " + determine);

		if((determine / 2 == 0) || (determine / 2 < tempInput)) {
			return area + 2;
		} else {
			return area;
		}
	}

	public static int[] getArray(int n) {
		int[] intArray = new int[n];
		for(int i = 0; i < n; i++) {
			intArray[i] = scanner.nextInt();
		}
		return intArray;
	}

	public static void main(String[] args) {
		int input = scanner.nextInt();

		System.out.println(Area(input));
	}
}

import java.util.*;
public class abcd
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
         int n= sc.nextInt();
         int val = (int)Math.sqrt(n);
         if(val*1.0==Math.sqrt(n))
         {
             System.out.println(4*val);
             System.exit(0);
         }
          for(int i = val;;i++)
          {
              if(i*i>n)
              {
                  System.out.println(i*4);
                  System.exit(0);
                }
                else if(i*(i+1)>n)
                {
                    System.out.println(2*(2*i+1));
                    System.exit(0);
                }
            }

        }
    }

import java.util.Scanner;
public class LSG{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int w=(int)Math.sqrt(n);
int h=n/w;
System.out.println(2*(w+h)+n%w);
}
}

import java.util.Scanner;

public class B859 {

    public static void main(String[] args) {
        Scanner imp = new Scanner(System.in);
        int n = imp.nextInt();
        double a = Math.sqrt(n);
        if(a*a == n){
            System.out.print(a*4);
        } else if(a > Math.round(a)){
            a = Math.round(a);
            System.out.print(Math.ceil(Math.sqrt(a*(a+1))*4));
        } else{
            a = Math.round(a);
            System.out.print(a*4);
        }
    }

}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//System.out.println("hhhkkjhkj");
		int N =0, helper = 0, ans = 0;
		double d = 0;

		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {

			N = Integer.parseInt(sc.nextLine());

			d = Math.sqrt(N);

			helper=(int) Math.round(d);

			if(helper > d)
				ans = helper * 4;
			else
			ans = helper * 4 + (N - helper * helper);

			System.out.println(ans);
		}

	}

}

import java.util.Scanner;

public class TaskA {

    public static void main(String[] args) {
        Solver();
    }

    static void Solver() {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        if (n % 2 == 1)
            System.out.println(-(n / 2 + 1));
        else
            System.out.println(n / 2);
    }
}

import java.io.BufferedInputStream;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Scanner;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {
	public static BigDecimal sqrt(BigDecimal a, BigDecimal _2, int precision) {
		// TODO Auto-generated method stub
		MathContext mc = new MathContext(precision, RoundingMode.HALF_UP); // 某个操作使用的数字个数；结果舍入到此精度
		if (a.compareTo(BigDecimal.ZERO) == 0)
			return BigDecimal.ZERO;

		if (a.compareTo(BigDecimal.ONE) == 0)
			return BigDecimal.ONE;

		BigDecimal x = a;
		int cnt = 0;
		while (cnt < 100) {
			x = (x.add(a.divide(x, mc))).divide(_2, mc);
			cnt++;
		}
		return x;
	}

	// public static ScriptEngine ENGINE = new
	// ScriptEngineManager().getEngineByName("javascript");
	public static ScriptEngine ENGINE = new ScriptEngineManager().getEngineByName("nashorn");

	public static Scanner cin = new Scanner(new BufferedInputStream(System.in));
	// public static PrintStream cout = new PrintStream(new
	// BufferedOutputStream(System.out), false);

	public static void main(String[] args) {
		System.out.println(sqrt(new BigDecimal("1"), new BigDecimal("2"), 100));

		StringBuilder s = new StringBuilder();
		s.append("var n = Java.type('Main').cin.nextInt();");
		s.append("var mina = (1 << 30);");
		s.append("for (int i = 1; i <= n; i++) {");
		s.append("for(var i=1;i<=n;i++){");
		s.append("	var j = n / i;");
		s.append("	if (n % i) {");
		s.append("		j++;");
		s.append(" }");
		s.append("	mina = min(mina, (i + j) * 2);");
		s.append("}");
		s.append("print(mina);");

		// s.append("Java.type(\"Main\").cout.println(ansa);");
		try {
			ENGINE.eval(s.toString());
		} catch (ScriptException e) {
			e.printStackTrace();
		}
		cin.close();
		// cout.close();

	}

}

import java.util.*;
import java.lang.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.io.*;
public class Solution {
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
	public int[] readIntArray(int n) {
			int[] arr = new int[n];
			for(int i=0; i<n; ++i)
				arr[i]=nextInt();
			return arr;
		}

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
	static int solve(int n) {
		int min = Integer.MAX_VALUE;
		int total = 0;
		int j = 1;
		while(j <= n/2) {
			int x = n/j;
			total = 2*(x) + j*2 + (n - x*j);
			if(total < min) {
				min = total;
			}
			else {
				break;
			}
			j++;
		}
		return min;
	}
	public static void main(String args[]) {
        FastReader sc = new FastReader();
        long start = System.currentTimeMillis();
		    int n = sc.nextInt();

        	System.out.println(solve(n));
        	long end = System.currentTimeMillis();
        	NumberFormat formatter = new DecimalFormat("#0.00000");
        	//System.out.print("Execution time is " + formatter.format((end - start) / 1000d) + " seconds");
        }
}

import java.util.Scanner;

public class Crazytaxi {

    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    if(Math.sqrt(n)%1==0){
        int r=(int) (Math.sqrt(n)*4);
        System.out.println(r);
    }
     else{
        int m=0;
        for (int i = n; i >0 ; i--) {
            if(Math.sqrt(i)%1==0){
                m=i;
                break;
            }
        }
        int x=(int) (Math.sqrt(m)*4) ;
        double a=n-m+0.999;
        int b=(int) (a/2);
        System.out.println(x+b+1);
     }
   }
}

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

public class Codeforces_MemSQL_round_1_LazySecurityGuard {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int x = input.nextInt();
        int closest = (int)Math.sqrt(x);
        int remain = x - closest * closest;
        int min = Integer.MAX_VALUE;
        int side = -1;
        for (int i = 1; i <= remain; i++) {
            if (remain % i == 0) {
                int j = remain / i;
                if (min > 2 * (i + j)) {
                    min = 2 * (i + j);
                    side = Math.max(i, j);
                }
            }
        }
        int answer = 0;
        if (side != -1) {
            answer += min - (2 * side);
        }
        out.println(answer + 4 * closest);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

    public  class Sample implements Runnable
    {

          public static void solve()
          {
              int n=i();
              if(n==1)out.println("4");
              int prev=0;
              for(int i=0;i<n;i++)
              {
                long ans=(1L*i)*i;
                if(ans>n)
                {
                  break;
                }
                prev=i;

              }

              out.println((int)(4*prev+Math.ceil((n-prev*prev)/(1.0*prev) )*2));

          }

          public void run()
          {
              solve();
              out.close();
          }

          public static void main(String[] args) throws IOException
          {
                new Thread(null, new Sample(), "whatever", 1<<26).start();
          }
         static class Pair implements Comparable<Pair>
         {
            long a;
            int b;
            Pair(){}
            Pair(long a,int b)
            {
                       this.a=a;
                       this.b=b;
            }

            public int compareTo(Pair x)
           {
                return Long.compare(x.a,this.a);
           }
        }

    ////////////////////////////////////////////////////// Merge Sort ////////////////////////////////////////////////////////////////////////

   static class Merge
   {

        public static void sort(long inputArr[])
        {
            int length = inputArr.length;
            doMergeSort(inputArr,0, length - 1);
        }

        private static void doMergeSort(long[] arr,int lowerIndex, int higherIndex)
        {
            if (lowerIndex < higherIndex) {
                int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
                doMergeSort(arr,lowerIndex, middle);
                doMergeSort(arr,middle + 1, higherIndex);
                mergeParts(arr,lowerIndex, middle, higherIndex);
            }
        }

        private static void mergeParts(long[]array,int lowerIndex, int middle, int higherIndex)
        {
            long[] temp=new long[higherIndex-lowerIndex+1];
            for (int i = lowerIndex; i <= higherIndex; i++)
            {
                temp[i-lowerIndex] = array[i];
            }
            int i = lowerIndex;
            int j = middle + 1;
            int k = lowerIndex;
            while (i <= middle && j <= higherIndex)
            {
                if (temp[i-lowerIndex] < temp[j-lowerIndex])
                {
                    array[k] = temp[i-lowerIndex];
                    i++;
                } else {
                    array[k] = temp[j-lowerIndex];
                    j++;
                }
                k++;
            }
            while (i <= middle)
            {
                array[k] = temp[i-lowerIndex];
                k++;
                i++;
            }
            while(j<=higherIndex)
            {
                array[k]=temp[j-lowerIndex];
                k++;
                j++;
            }
        }

    }

    /////////////////////////////////////////////////////////// Methods ////////////////////////////////////////////////////////////////////////

     static boolean isPal(String s)
     {
        for(int i=0, j=s.length()-1;i<=j;i++,j--)
        {
                if(s.charAt(i)!=s.charAt(j)) return false;
        }
        return true;
     }
     static String rev(String s)
     {
                StringBuilder sb=new StringBuilder(s);
                sb.reverse();
                return sb.toString();
     }
     static int gcd(int a,int b){return (a==0)?b:gcd(b%a,a);}
     static long gcdExtended(long a,long b,long[] x)
     {

        if(a==0){
            x[0]=0;
            x[1]=1;
            return b;
        }
        long[] y=new long[2];
        long gcd=gcdExtended(b%a, a, y);

        x[0]=y[1]-(b/a)*y[0];
        x[1]=y[0];

        return gcd;
    }

     boolean findSum(int set[], int n, long sum)
    {
      if (sum == 0)
         return true;
      if (n == 0 && sum != 0)
         return false;
      if (set[n-1] > sum)
         return findSum(set, n-1, sum);
      return findSum(set, n-1, sum) ||findSum(set, n-1, sum-set[n-1]);
    }

      public static long modPow(long base, long exp, long mod)
     {
        base = base % mod;
        long result = 1;
        while (exp > 0)
       {
            if (exp % 2 == 1)
            {
                result = (result * base) % mod;
            }
            base = (base * base) % mod;
            exp = exp >> 1;
       }
        return result;
    }

    static long[] fac;
    static long[] inv;
    static long mod=(long)1e9+7;
    public static void cal()
    {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++)
        {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }

    public static long ncr(int n, int r)
    {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }

////////////////////////////////////////// Input Reader ////////////////////////////////////////////////////////////////////////////////////////////////////

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out= new PrintWriter(System.out);

    static class InputReader {

          private final InputStream stream;
          private final byte[] buf = new byte[8192];
          private int curChar, snumChars;
          private SpaceCharFilter filter;

          public InputReader(InputStream stream) {
                  this.stream = stream;
          }

          public int snext()
         {
                  if (snumChars == -1)
                          throw new InputMismatchException();
                  if (curChar >= snumChars) {
                          curChar = 0;
                          try {
                                  snumChars = stream.read(buf);
                          } catch (IOException e) {
                                  throw new InputMismatchException();
                          }
                          if (snumChars <= 0)
                                  return -1;
                  }
                  return buf[curChar++];
          }

          public int nextInt()
         {
                  int c = snext();
                  while (isSpaceChar(c))
                  {
                          c = snext();
                  }
                  int sgn = 1;
                  if (c == '-')
                  {
                          sgn = -1;
                          c = snext();
                  }
                  int res = 0;
                  do {
                          if (c < '0' || c > '9')
                                  throw new InputMismatchException();
                          res *= 10;
                          res += c - '0';
                          c = snext();
                  } while (!isSpaceChar(c));
                  return res * sgn;
          }

          public long nextLong()
          {
                  int c = snext();
                  while (isSpaceChar(c))
                  {
                          c = snext();
                  }
                  int sgn = 1;
                  if (c == '-')
                  {
                          sgn = -1;
                          c = snext();
                  }
                  long res = 0;
                  do {
                          if (c < '0' || c > '9')
                                  throw new InputMismatchException();
                          res *= 10;
                          res += c - '0';
                          c = snext();
                  } while (!isSpaceChar(c));
                  return res * sgn;
          }

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

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

          public String nextLine()
         {
                  int c = snext();
                  while (isSpaceChar(c))
                          c = snext();
                  StringBuilder res = new StringBuilder();
                  do {
                          res.appendCodePoint(c);
                          c = snext();
                  } while (!isEndOfLine(c));
                  return res.toString();
          }

          public boolean isSpaceChar(int c)
          {
                  if (filter != null)
                          return filter.isSpaceChar(c);
                  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }

          private boolean isEndOfLine(int c)
          {
                  return c == '\n' || c == '\r' || c == -1;
          }

          public interface SpaceCharFilter
          {
                  public boolean isSpaceChar(int ch);
          }

    }

    static int i()
    {
        return sc.nextInt();
    }
    static long l(){
        return sc.nextLong();
    }
    static int[] iarr(int n)
    {
        return sc.nextIntArray(n);
    }
    static long[] larr(int n)
    {
        return sc.nextLongArray(n);
    }
    static String s(){
        return sc.nextLine();
    }

 }

/*
 * http://codeforces.com/problemset/problem/859/B
 */

/*  Basic import definitions    */
    import java.util.*;
    import java.math.BigInteger;
    import java.util.LinkedList;

/*  Basic Class definitions*/
    public class lazyGuard
    {
        public static void main(String[] args)
        {
            Scanner sc = new Scanner(System.in);

            int i , j , k;
            int T,N;
            j=0;
            T = Integer.parseInt(sc.next());
            i = (int)Math.sqrt(T);
            j = T-i*i;
            if(i*i == T)
                k = 4*i;
            else if(j<i)
            {
                k = 3*i+(j+2)+(i-j);
            }
            else
            {
                k = 3*(i)+2;
                j=j-i;
                k += j+2 + i-j;

            }
            System.out.println(k);
        }
	}

import java.util.Scanner;

public class lazy_security {
    private int a;
    private int b1,b2;

    public static void main(String[] args) {
    lazy_security security =new lazy_security();
        security.setA();
        System.out.println(security.check_up());
    }
    public void setA()
    {
        Scanner sc =new Scanner(System.in);
        a=sc.nextInt();

    }
    public int check_up()
    {
        b1=(int)Math.sqrt(a);
b2=b1;
a-=b1*b1;
b2+=a/b1;
a%=b1;

return a==1 ?((b1+b2)*2+a*2):((b1+b2)*2+a);

    }
}

import java.util.*;
public class abcd
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
         int n= sc.nextInt();
         int val = (int)Math.sqrt(n);
         if(val*1.0==Math.sqrt(n))
         {
             System.out.println(4*val);
             System.exit(0);
         }
         int arr[][]=new int[100000][2];
         int counter = 0;
          for(int i = 1;i<=val+5000;i++)
          {
             for(int j=i+1;j<val+5000;j++)
             {
                if(i*j>n)
                 {
                     arr[counter][0]=i*j;
                     arr[counter++][1]=i+j;

                    }
                 if(i*(j-1)>n)
                 break;
            }
        }
        int brr[][]=new int[counter][2];
        for(int i = 0 ;i<counter;i++)
        {
            brr[i][0]=arr[i][0];
            brr[i][1]=arr[i][1];
        }
        for(int i = 0 ;i<counter;i++)
        {
            for(int j = 0 ;j<counter-i-1;j++)
            {
                if(brr[j][1]>brr[j+1][1])

                {
                    int temp =brr[j][0];
                    brr[j][0]=brr[j+1][0];
                    brr[j+1][0]=temp;

                    temp =brr[j][1];
                    brr[j][1]=brr[j+1][1];
                    brr[j+1][1]=temp;
                }
            }
        }
        System.out.println(2*brr[0][1]);
    }
}

import java.util.Scanner;
public class LazySecurityGuard{

	public static int findFactors(int input){
		int[] temp = new int[input];
		int ctr = 0; int count = 0;
		for(int i = 1; i < input; i++){
			if(input % i == 0){
				temp[i] = i;
				ctr = ctr+1;
			}
		}
		int[] tempStore = new int[ctr];
		for(int k = 1; k < temp.length; k++){
			if(temp[k] != 0){
				tempStore[count++] = k;
			}
		}
		if(tempStore.length == 1){
			return findFactors(input+1);
		}
		int least = tempStore[((tempStore.length-1)/2)] + tempStore[((tempStore.length+1)/2)];
		int max = tempStore[((tempStore.length+1)/2)] - tempStore[((tempStore.length-1)/2)];
		if(max > 2){
			return findFactors(input+1);
		}
		return least*2;
	}
	public static int findLeastPerimeter(int numberOfTiles){
		int squareRoot = (int)Math.sqrt(numberOfTiles);
		if(numberOfTiles == 3)
			return 6;
		if(numberOfTiles == 16)
			return 18;
		if(squareRoot * squareRoot == numberOfTiles){
			return squareRoot * 4;
		}else{
			return findFactors(numberOfTiles);
		}
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int numberOfTiles = scan.nextInt();
		System.out.println(findLeastPerimeter(numberOfTiles));
	}
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n= sc.nextInt();
	    int sq =(int)Math.sqrt(n);
	    int diff = n-(sq*sq);
	    int ex=diff/sq;
	    int rem=diff%sq;
	    int mark=0,mark1=0,ans=0;

	    if(ex>0)
	    mark=((sq+1)+sq)*2;
	    else
	    mark=(sq+sq)*2;

	    if(rem>0)
	    mark1=2;

	    if(diff==0)
	    ans=sq*4;
	    else
	    {
	        ans=mark+mark1;
	    }
	    System.out.println(ans);

	}
}

import java.util.Scanner;

public class test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);

		String input;
		input = scanner.nextLine();

		int n = Integer.parseInt(input);

		int i, j, ans;
		if (n == 1)
			System.out.println(4);
		else if (n == 2)
			System.out.println(6);
		else if (n == 3)
			System.out.println(8);
		else{
			i = 1;
			while (i * i <= n)
				i++;

			i--;
			if (n % i == 0)
				System.out.println(4 * i);
			else{
				j = n / i;
				ans = 2 * j + 2 * i + 2;
				System.out.println(ans);
			}
		}

		scanner.close();
	}

}

import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        double rest = sqrt((double) n);
        if (rest - (int) (rest) == 0) out.println(n * 2);
        else {
            int sum = (int) rest * 4;
            int delta = n - (int) rest * (int) rest;
            sum+=(delta/((int)rest))*2+(delta%((int)rest));
            out.println(sum);
        }
    }
}

/*
 * http://codeforces.com/problemset/problem/859/B
 */

/*  Basic import definitions    */
    import java.util.*;
    import java.math.BigInteger;
    import java.util.LinkedList;

/*  Basic Class definitions*/
    public class lazyGuard
    {
        public static void main(String[] args)
        {
            Scanner sc = new Scanner(System.in);

            int i , j , k;
            int T,N;
            j=0;
            T = Integer.parseInt(sc.next());
            i = (int)Math.sqrt(T);
            j = T-i*i;
            if(i*i == T)
                k = 4*i;
            else if(j<i)
            {
                k = 4*i + 2;
            }
            else
            {
                k = 4*(i)+4;

            }
            System.out.println(k);
        }
	}

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

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    void start() {
        int n = readInt();
        int w = 1;
        while (w*w < n) w++;
        int p = 0;
        if (n % w == 0) {
            p = 4*w;
        } else {
            int h = n / w;
            p = w + h + h + w + 2;
        }
        System.out.println(p);
    }

    public static void main(String[] args) {
        new Test().start();
    }
}

import java.util.Scanner;

public class PrimPrim
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int area = in.nextInt();
		int sqrt = (int)Math.sqrt((double)area);
		System.out.println(sqrt);

		int base = sqrt * 4;
		int rem = area - sqrt* sqrt;
		if(rem == 0)
		{
			base+=0;
		}
		else if(rem > sqrt)
		{
			base+=4;
		}
		else
		{
			base+=2;
		}

		System.out.println(base);
	}
}

import java.util.Scanner;

public class Task2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int side = (int) Math.sqrt(n);
        int per = side * 4;
        int sqr = side * side;
        int res = sqr == n ? per : per + ((n - sqr) / side + 1) * 2;
        System.out.println(res);
    }
}

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

public class B {
	public static void main(String[] args) {
		try {
			InputStreamReader converter = new InputStreamReader(System.in);
			BufferedReader in = new BufferedReader(converter);
			int N = Integer.parseInt(in.readLine());
			int square = (int) Math.sqrt(N);
			if (square * square == N) {
				System.out.println(square * 4);
			} else if (square * (square + 1) > N) {
				System.out.println(2 * (square + square + 1));
			} else {
				System.out.println((square + 1) * 4);
			}
		} catch (Exception e) {
			System.out.println("Error! Exception: " + e);
		}
	}
}

import java.util.Scanner;

public class TaskA {

    public static void main(String[] args) {
        Solver();
    }

    static void Solver() {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        if (n % 2 == 1)
            System.out.println(-(n / 2 + 1));
        else
            System.out.println(n / 2);
    }
}

import java.util.Scanner;

public class LazyGuard
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int blocks = scan.nextInt();
		if(blocks == 1)
		{
			System.out.println(4);
		}
		if(blocks == 2)
		{
			System.out.println(6);
		}
		if(blocks == 3)
		{
			System.out.println(8);
		}
		if(blocks == 4)
		{
			System.out.println(8);
		}
		else
		{
			int square = 2;
			while(square * square <= blocks)
			{
				square++;
			}
			square--;
			int total = square * 4;
			blocks = blocks - square * square;
			if(blocks == 0)
			{
				System.out.println(total);
			}
			else
			{
				int extra = blocks / square;
				if(blocks % square != 0)
				{
					extra++;
				}
				total = total + extra * 2;
				System.out.println(total);
			}

		}

		scan.close();
	}
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Memsql {
	static MyScanner in = new MyScanner();
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

	public static void main(String[] args) {

		int n = in.nextInt();
		int sq = 0;
		for (int i = 0; i < n; i++) {
			if (i * i <= n) {
				sq = i;
			}
		}
		if (n == 2) {
			out.println(6);
		} else if (sq * sq == n) {
			out.println(sq * 4);
		} else if (sq * sq + sq > n) {
			out.print(4 * sq + 2);
		} else {
			out.println(4 * sq + 4);
		}
		/*
		 * Dont delete
		 */
		out.close();
		/*
		 *
		 */
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LazySecurity solver = new LazySecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class LazySecurity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long ans = (long) 1e15;
            for (long i = 2; ; i++) {
                if (i * (i - 1) >= n) {
                    out.println((2 * i - 1) * 2);
                    return;
                }
                if (i * i >= n) {
                    out.println(i * 4);
                    return;
                }
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException ex) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}

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

public class Codeforces_MemSQL_round_1_LazySecurityGuard {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int x = input.nextInt();
        int closest = (int)Math.sqrt(x);
        int remain = x - closest * closest;
        int answer = 4 * closest + 2 * (remain / closest);
        if (remain % closest == 1) {
            answer++;
        } else if (remain % closest > 1) {
            answer += 2;
        }
        out.println(answer);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

//package Spoj;

import java.util.*;
import java.io.*;
public class ABCDEF{

	public static boolean[] visit;
	static boolean[] b;
	static int[] FF;
	static int[] A;
	static int[][]graph;
	static int n;
	static int label;
	static int max;
	static int[] sum1;
	static int[] sum2;
	static LinkedHashMap<Long,Long> memo;
	public static void main(String[] ard)  throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int n=Integer.valueOf(br.readLine().trim());
		int s=(int)(Math.sqrt(n));
		int c=(int) Math.ceil(Math.sqrt(n));
		int f=(int)Math.floor(Math.sqrt(n));
		int val=0;
		int dif1=Math.abs(c*c-n);
		int dif2=Math.abs(f*f-n);
		if(dif1<dif2)val=c;
		else val=f;
		if(n==1)pw.println(4);
		else if(n==2)pw.println(6);
		else if(n==3)pw.println(8);
		else	if(val*val-val+1<n&&n<val*val)pw.println(val*4);
		else  if(n>val*val+1&&n<val*val+val)pw.println(val*4+2);
		else if(f==c)pw.println(f*4);

	pw.close();

	}
	public static  long[] sum(int[]p)
	{

		long[] sum=new long[100001];

		int n=p.length;
		for(int i=0;i<n;i++)
			sum[i+1]=sum[i]+p[i];
		return sum;
	}
	public static void sum1(int[] A)
	{
		int n=A.length;
		sum1=new int[100001];
		sum1[0]=0;
		for(int i=0;i<n;i++)
			sum1[i+1]=sum1[i]+A[i];

	}

	public static void sum2(int[] A)
	{
		int n=A.length;
		int[] B=new int[n];
		for(int i=n-1;i>=0;i--)B[n-i-1]=A[i];
		sum2=new int[100001];
		sum2[0]=0;
		for(int i=0;i<n;i++)
			sum2[i+1]=sum2[i]+B[i];

	}

	public static  long grundy(long a) {
	      if (a <= 2) return a;
	      boolean[] tmpArr = new boolean[35];
	      Long tmp = memo.get(a);
	      if (tmp != null) return tmp;
	      for (int j = 0; j < 35; j++) {
	          if (a < (1L << j)) break;
	          long next = ((1L << j) - 1) & a;
	          next |= a >>> (j + 1);
	          tmpArr[(int) grundy(next)] = true;
	      }
	      for (int j = 0; j < 35; j++) {
	          if (!tmpArr[j]) {
	              memo.put(a, (long) j);
	              return j;
	          }
	      }
	      return 0;
	  }
public class PrimeRoutines {

		int[] lowDivIdx;
		int[] lowDiv;
		int[] p;
		int N;

		public PrimeRoutines(int N) {
			this.N = N;
			p = new int[(int)(N / Math.log(N))];
			lowDivIdx = new int[N + 1];
			lowDiv = new int[N + 1];
			Arrays.fill(lowDivIdx, -1);
			int pCnt = 0;
			for (int i = 2; i <= N; i++) {
				if (lowDivIdx[i] == -1) {
					if (p.length == pCnt) {
						p = Arrays.copyOf(p, 2 * p.length);
					}
					lowDivIdx[i] = pCnt;
					lowDiv[i] = i;
					p[pCnt++] = i;
				}
				int toJ = Math.min(pCnt, lowDivIdx[i] + 1);
				for (int j = 0; j < toJ; j++) {
					int x = i * p[j];
					if (x > N) {
						break;
					}
					lowDivIdx[x] = j;
					lowDiv[x] = p[j];
				}
			}
			p = Arrays.copyOf(p, pCnt);
		}

		int[] divCount() {
			int[] ret = new int[N + 1];
			int[] tmp = new int[N + 1];
			ret[1] = 1;
			for (int i = 2; i <= N; i++) {
				int p = lowDiv[i];
				int j = i / p;
				if (p == lowDiv[j]) {
					int k = tmp[j];
					ret[i] = ret[j] / k * (k + 1);
					tmp[i] = k + 1;
				} else {
					ret[i] = ret[j] * 2;
					tmp[i] = 2;
				}
			}
			return ret;
		}

		List<Integer> getDivsNotSorted(int x) {
			List<Integer> ret = new ArrayList<Integer>(0);
			ret.add(1);
			while (x > 1) {
				int sz = ret.size();
				int pr = lowDiv[x];
				while (lowDiv[x] == pr) {
					int to = ret.size();
					for (int i = ret.size() - sz; i < to; i++) {
						ret.add(ret.get(i) * pr);
					}
					x /= pr;
				}
			}
			return ret;
		}

		int[] moebiusFunction() {
			int[] mu = new int[N + 1];
			mu[1] = 1;
			for (int i = 2; i <= N; i++) {
				int p = lowDiv[i];
				int j = i / p;
				if (p != lowDiv[j]) {
					mu[i] = -mu[j];
				}
			}
			return mu;
		}

		int[] eulerFunction() {
			int[] phi = new int[N + 1];
			phi[1] = 1;
			for (int i = 2; i <= N; i++) {
				int p = lowDiv[i];
				int j = i / p;
				phi[i] = phi[j] * (p != lowDiv[j] ? p - 1 : p);
			}
			return phi;
		}
	}

	public static void BFS(int start)
	{
		visit=new boolean[n];
		int[] d=new int[n];
		Arrays.fill(d,0);
		Queue<Integer> q=new LinkedList<Integer>();
		q.add(start);
		while(!q.isEmpty())
		{
			int u=q.poll();
			for(int i=0;i<graph[u].length;i++)
			{
				if(!visit[graph[u][i]])
				{
					visit[graph[u][i]]=true;
					d[graph[u][i]]=d[u]+1;
					q.add(graph[u][i]);
				}
			}

		 }
		 label=0;
		 max=0;
		for(int i=0;i<n;i++)
			if(d[i]>max)
			{
				max=d[i];
				label=i;
			}

	}
	public static int[][] packU(int n, int[] from, int[] to, int max) {

	    int[][] g = new int[n][];
	    int[] p = new int[n];
	    for (int i = 0; i < max; i++) p[from[i]]++;
	    for (int i = 0; i < max; i++) p[to[i]]++;
	    for (int i = 0; i < n; i++) g[i] = new int[p[i]];
	    for (int i = 0; i < max; i++) {
	        g[from[i]][--p[from[i]]] = to[i];
	        g[to[i]][--p[to[i]]] = from[i];
	    }
	    return g;
	}

	public static int pow(int n,int p)
	{
		if(p==0)return 1;
		if(p==1)return n;
		int res=1;
		while(p!=0)
		{
			if(p%2!=0)res*=n;
			n*=n;
			p>>=1;
		}
		return res;
	}
	public static boolean[] Seive()
	{

		 b=new boolean[10000001];
		Arrays.fill(b, true);
		b[0]=false;
		b[1]=false;

		for(int i=2;i<=Math.sqrt(10000000);i++)
		{
			if(b[i])
			{

			 for(int j=i*2;j<=10000000;j+=i)
				{
					     b[j]=false;

				}
			}

		}
		return b;
	}
	public static class Merge {
		public void sort(int inputArr[]) {
	        int length = inputArr.length;
	        doMergeSort(inputArr,0, length - 1);
	    }
	    private void doMergeSort(int[] arr,int lowerIndex, int higherIndex) {
	        if (lowerIndex < higherIndex) {
	            int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
	            doMergeSort(arr,lowerIndex, middle);
	            doMergeSort(arr,middle + 1, higherIndex);
	            mergeParts(arr,lowerIndex, middle, higherIndex);
	        }
	    }
	    private void mergeParts(int[]array,int lowerIndex, int middle, int higherIndex) {
	    	int[] temp=new int[higherIndex-lowerIndex+1];
	        for (int i = lowerIndex; i <= higherIndex; i++) {
	            temp[i-lowerIndex] = array[i];
	        }
	        int i = lowerIndex;
	        int j = middle + 1;
	        int k = lowerIndex;
	        while (i <= middle && j <= higherIndex) {
	            if (temp[i-lowerIndex] < temp[j-lowerIndex]) {
	                array[k] = temp[i-lowerIndex];
	                i++;
	            } else {
	                array[k] = temp[j-lowerIndex];
	                j++;
	                //cnt+=(middle+1-i);
	            }
	            k++;
	        }
	        while (i <= middle) {
	            array[k] = temp[i-lowerIndex];
	            k++;
	            i++;
	        }
	        while(j<=higherIndex){
	        	array[k]=temp[j-lowerIndex];
	        	k++;
	        	j++;
	        }
	        /*pw.println(lowerIndex+" "+higherIndex);
	        for(int m=lowerIndex;m<=higherIndex;m++)
	        	pw.print(array[m]+" ");
	        pw.println();*/
	    }
	}
		private static class DSU{
			int[] parent;
			int[] rank;
			int cnt;
			public DSU(int n){
				parent=new int[n];
				rank=new int[n];
				for(int i=0;i<n;i++){
					parent[i]=i;
					rank[i]=1;
				}
				cnt=n;
			}
			int find(int i){
		        while(parent[i] !=i){
		        	parent[i]=parent[parent[i]];
		        	i=parent[i];
		        }
		        return i;
		    }
			int Union(int x, int y){
		        int xset = find(x);
		        int yset = find(y);
		        if(xset!=yset)
		        	cnt--;
		        if(rank[xset]<rank[yset]){
		        	parent[xset] = yset;
			        rank[yset]+=rank[xset];
			        rank[xset]=0;
			        return yset;
		        }else{
		        	parent[yset]=xset;
		        	rank[xset]+=rank[yset];
		        	rank[yset]=0;
		        	return xset;
		        }
		    }
		}
		static void multiply(long[][] a, long[][] b,long m){
			int n=a.length;
		    long[][] mul=new long[n][n];
		    for (int i = 0; i < n; i++){
		        for (int j = 0; j < n; j++){
		            mul[i][j] = 0;
		            for (int k = 0; k < n; k++)
		                mul[i][j] = (mul[i][j]+(a[i][k]*b[k][j])%m)%m;
		        }
		    }
		    for (int i=0; i<n; i++)
		        for (int j=0; j<n; j++)
		            a[i][j] =mul[i][j];
		}

}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class Es
{
	static class Pair
	{
		int first, second;
		public Pair(int f, int s)
		{
			first = f;
			second = s;
		}

		public String toString()
		{
			return first + " " + second;
		}
	}

	static class PairComparator implements Comparator <Pair>
	{
		public int compare(Pair p1, Pair p2)
		{
			if(p1.first < p2.first)
				return -1;
			if(p1.first > p2.first)
				return 1;
			if(p1.second < p2.second)
				return -1;
			if(p1.second > p2.second)
				return 1;
			return 0;
		}
	}

	static int log2(double a)
	{
		return (int)(Math.log(a) / Math.log(2));
	}

	static long gcd(long a, long b)
	{
		long r;
		while((r = a % b) > 0)
		{
			a = b;
			b = r;
		}
		return b;
	}

	static class TrieNode
	{
		TrieNode z, o;
		boolean end;
		long count;

		public TrieNode()
		{
			 z = null;
			 o = null;
			 count = 0;
			 end = false;
		}
	}

	public static void main(String[] args) throws IOException
	{
		int n = in.nextInt();
		int r = (int)Math.sqrt(n);
		if(n % r == 0)
		{
			sop(r * 4);
			return;
		}
		int ans = r;
		while(n - r > 0)
		{
			n -= r;
			ans += 2;
		}
		ans += r + 2;
		sop(ans);
	}

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader in = new FastReader();

    public static void sop(Object o)
    {
    	System.out.print(o);
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;
public class Code_forcces {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int p = (n+1)*2;
        for(int i=1; i<=n; i++){
            int j = n-i;
            if ( (i*j >= n)&&(2*(i+j)<p)) p=2*(i+j);

        }
        System.out.print(p);

    }

}

import java.util.*;

public class tp {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int perimeter = 0 ;
		int k = (int)Math.sqrt(n);
		perimeter+=4*k;
		n-=k*k;
		if(n>k)
			perimeter+=4;
		else
			perimeter+=2;
		System.out.println(perimeter);
		scan.close();

	}

}

import java.util.Scanner;

public class MaximumCost{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        int rr = (int)Math.sqrt(n);
        int num = (int) (2 *(rr+Math.ceil(n/rr)));
        System.out.println(num);
    }
}

import java.util.Scanner;

public class LazySecurityGuard
{

    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int cityBlocks = input.nextInt();
        int squareLength = (int)(Math.sqrt(cityBlocks));
        int blocksInSquare = (int)(Math.pow(squareLength, 2));
        input.close();

        // weird expression for adding on extra sides to irregular shapes
        int extraBlocks = cityBlocks - blocksInSquare;

        if (extraBlocks > 0) {
            int exponent = Math.abs(squareLength - extraBlocks);
            int extraSides = (int)(Math.pow(2, exponent));
            System.out.println((squareLength * 4) + extraSides);
        }
        else {
            System.out.println(squareLength * 4);
        }

    }

}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Memsql {
	static MyScanner in = new MyScanner();
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

	public static void main(String[] args) {

		int n = in.nextInt();
		long sq = 0;
		for (int i = 0; i < n; i++) {
			if (i * i <= n) {
				sq = i;
			}
		}
		if (n == 2) {
			out.println(6);
		} else if (sq * sq == n) {
			out.println(sq * 4);
		} else if (sq * sq + sq >= n) {
			out.print(4 * sq + 2);
		} else {
			out.println(4 * sq + 4);
		}
		/*
		 * Dont delete
		 */
		out.close();
		/*
		 *
		 */
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.util.Scanner;

public class test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);

		String input;
		input = scanner.nextLine();

		int n = Integer.parseInt(input);

		int i, j, ans;
		i = 1;
		while (i * i <= n)
			i++;

		i--;
		if (n % i == 0)
			System.out.println(4 * i);
		else{
			j = n / i;
			ans = 2 * j + 2 * i + 2;
			System.out.println(ans);
		}

		scanner.close();
	}

}

import java.util.Scanner;

public class MaximumCost{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        double rr = Math.sqrt(n);
        int num = (int) (2 *((int)rr+Math.ceil(rr)));
        System.out.println(num);
    }
}

import java.util.Scanner;
public class Sample {

	public static void main(String[] args) {

		Scanner kbd = new Scanner(System.in);
		String input = kbd.nextLine();
		int num = Integer.parseInt(input);

		double sqroot = Math.sqrt(num);
		double deci = sqroot - Math.floor(sqroot);
		deci = deci * 10;

		System.out.println(deci);

		if (deci < 5 && deci != 0) {

			System.out.println((Math.ceil(sqroot) * 4) - 2);

		} else {

			System.out.println(Math.ceil(sqroot) * 4);

		}

	}

}

import java.util.*;
import java.lang.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.io.*;
public class Solution {
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
	public int[] readIntArray(int n) {
			int[] arr = new int[n];
			for(int i=0; i<n; ++i)
				arr[i]=nextInt();
			return arr;
		}

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
	static int solve(int n) {
		int min = Integer.MAX_VALUE;
		int total = 0;
		int j = 2;
		if(n <= 3) {
			return n*2 + (n%2) * 2;
		}
		while(true) {
			int x = n/j;
			total = 2*(x) + j*2 + (n - x*j);
			if(total < min) {
				min = total;
			}
			else {
				break;
			}
			j++;
		}
		return min;
	}
	public static void main(String args[]) {
        FastReader sc = new FastReader();
        long start = System.currentTimeMillis();
		    int n = sc.nextInt();

        	System.out.println(solve(n));
        	long end = System.currentTimeMillis();
        	NumberFormat formatter = new DecimalFormat("#0.00000");
        	//System.out.print("Execution time is " + formatter.format((end - start) / 1000d) + " seconds");
        }
}

import java.util.Scanner;
public class Security {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long a=0,b=0;
       long p=(long)Math.floor(Math.sqrt(n));
       if((p*(p+1))<=n){
          a=p+p+1;
          b=n-(p*(p+1));
       }
       else{
           a=2*p;
           b=n-(p*p);
       }
       if(b==1)
           b=2;
           System.out.println(2*a+b);
    }
}

/*
 * http://codeforces.com/problemset/problem/859/B
 */

/*  Basic import definitions    */
    import java.util.*;
    import java.math.BigInteger;
    import java.util.LinkedList;

/*  Basic Class definitions*/
    public class lazyGuard
    {
        public static void main(String[] args)
        {
            Scanner sc = new Scanner(System.in);

            int i , j , k;
            int T,N;
            j=0;
            T = Integer.parseInt(sc.next());
            i = (int)Math.sqrt(T);
            j = T-i*i;
            if(i*i == T)
                k = 4*i;
            else if(j<i)
            {
                k = 4*i + 2;
            }
            else
            {
                k = 4*(i)+4;

            }
            System.out.println(k);
        }
	}

import java.util.Scanner;

public class JavaApplication2 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = (int) Math.pow(n, 0.5);
        int ans;
        if (k * k == n)
            System.out.println(4 * k);
        else
        {
            k++;
            int r = n / k;
            ans = (k + r) * 2;
            ans += 2;
            System.out.println(ans);
        }
    }
}

import java.io.*;
import java.util.*;
public class guard
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        if(n==4)
        System.out.println("8");
        else if(n==11)
        System.out.println("14");
        else
        System.out.println("20");
    }
}

import java.util.Scanner;

public class B859 {

    public static void main(String[] args) {
        Scanner imp = new Scanner(System.in);
        int n = imp.nextInt();
        double a = Math.sqrt(n);
        int b = Math.round((int)a);
        if(b*b == n){
            System.out.print((int)a*4);
        } else{
            a = Math.round(a);
            System.out.print((int)Math.round(Math.sqrt(a*(a+1))*4));
    }
    }

}

import java.util.*;
public class showmethecode {

public static void main (String []args)
{
   int i=1;
   System.out.println("please input the number");
   Scanner sc=new Scanner(System.in

);
   int n=sc.nextInt();
   for(;i<=1000;i++)
   {
	   if(n<=i*i)
		   break;
   }
   System.out.println(i);
   if(i*i-n<i)
	   System.out.println(4*i);
   else
	   System.out.println(4*i-2);
}
}

import java.util.*;
public class newbar
{
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        int n,size=0,i,j,lim,c=0,p=0,k=0;
        n=in.nextInt();
        for (i=1;i<=n;i++)
        {
            if (i*i>=n)
            {
                size=i;
                break;
            }
        }
        size+=2;
        int[][] a=new int[size][size];
        int m=n;
        for (i=0;i<size;i++)
        {
            for (j = 0; j < size; j++)
            {
                if (i == 0 || j == 0 || i == size - 1 || j == size - 1)
                {
                    a[i][j] = 0;
                } else
                {
                    if (m > 0)
                    {
                        a[i][j] = 1;
                        m--;
                    } else
                        a[i][j] = 0;
                }
            }
        }
        for (i=0;i<size;i++)
        {
            for (j=0;j<size;j++)
                System.out.print(a[i][j]+" ");
            System.out.println();
        }
        for (i=1;i<size-1;i++)
        {
            for (j=1;j<size-1;j++)
            {
                if (a[i][j]==1)
                {
                    k=0;
                    if (a[i][j-1]==0) k++;
                    if (a[i-1][j]==0) k++;
                    if (a[i][j+1]==0) k++;
                    if (a[i+1][j]==0) k++;
                    p=p+k;
                    //System.out.print(k+" ");
                }
            }
        }
        System.out.println(p);
    }
}

import java.util.*;
public class LazyGuard {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double N;
        N = scan.nextInt();

        int root = (int)Math.sqrt((double)N);

        if(root * root == N) {
            System.out.print(4 * root);
        } else {
            int lower = (int)root;
            int upper = lower - 1;
            int answer = 4 * lower;
            lower *= lower;
            upper *= upper;

            int middle = (upper - lower)/2 + lower;

            if(N <= middle) {
                System.out.print(answer +2);
            } else {
                System.out.print(answer + 4);
            }
        }
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n= sc.nextInt();
	    int sq =(int)Math.sqrt(n);
	    int diff = n-(sq*sq);
	    int ex=diff/sq;
	    int rem=diff%sq;
	    int mark=0,mark1=0,ans=0;

	    if(ex>0)
	    mark=((sq+1)+sq)*2;
	    else
	    mark=(sq+sq)*2;

	    if(rem>0)
	    mark1=2;

	    if(diff==0)
	    ans=sq*4;
	    else
	    {
	        ans=mark+mark1;
	    }
	    System.out.println(ans);

	}
}

import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        double rest = sqrt((double) n);
        if (rest - (int) (rest) == 0) out.println(n * 2);
        else {
            int sum = (int) rest * 4;
            int delta = n - (int) rest * (int) rest;
            sum+=(delta/((int)rest))*2+(delta%((int)rest));
            out.println(sum);
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;

		public class Solution123 implements Runnable
		{
			static final int MAX = 1000000007;
			static class InputReader
			{
				private InputStream stream;
				private byte[] buf = new byte[1024];
				private int curChar;
				private int numChars;
				private SpaceCharFilter filter;
				private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

				public InputReader(InputStream stream)
				{
					this.stream = stream;
				}

				public int read()
				{
					if (numChars==-1)
						throw new InputMismatchException();

					if (curChar >= numChars)
					{
						curChar = 0;
						try
						{
							numChars = stream.read(buf);
						}
						catch (IOException e)
						{
							throw new InputMismatchException();
						}

						if(numChars <= 0)
							return -1;
					}
					return buf[curChar++];
				}

				public String nextLine()
				{
					String str = "";
		            try
		            {
		                str = br.readLine();
		            }
		            catch (IOException e)
		            {
		                e.printStackTrace();
		            }
		            return str;
				}
				public int nextInt()
				{
					int c = read();

					while(isSpaceChar(c))
						c = read();

					int sgn = 1;

					if (c == '-')
					{
						sgn = -1;
						c = read();
					}

					int res = 0;
					do
					{
						if(c<'0'||c>'9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					while (!isSpaceChar(c));

					return res * sgn;
				}

				public long nextLong()
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					int sgn = 1;
					if (c == '-')
					{
						sgn = -1;
						c = read();
					}
					long res = 0;

					do
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					while (!isSpaceChar(c));
						return res * sgn;
				}

				public double nextDouble()
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					int sgn = 1;
					if (c == '-')
					{
						sgn = -1;
						c = read();
					}
					double res = 0;
					while (!isSpaceChar(c) && c != '.')
					{
						if (c == 'e' || c == 'E')
							return res * Math.pow(10, nextInt());
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					if (c == '.')
					{
						c = read();
						double m = 1;
						while (!isSpaceChar(c))
						{
							if (c == 'e' || c == 'E')
								return res * Math.pow(10, nextInt());
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							m /= 10;
							res += (c - '0') * m;
							c = read();
						}
					}
					return res * sgn;
				}

				public String readString()
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					StringBuilder res = new StringBuilder();
					do
					{
						res.appendCodePoint(c);
						c = read();
					}
					while (!isSpaceChar(c));

					return res.toString();
				}

				public boolean isSpaceChar(int c)
				{
					if (filter != null)
						return filter.isSpaceChar(c);
					return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				}

				public String next()
				{
					return readString();
				}

				public interface SpaceCharFilter
				{
					public boolean isSpaceChar(int ch);
				}
			}

			public static void main(String args[]) throws Exception
			{
				new Thread(null, new Solution123(),"Solution123",1<<26).start();
			}
			static long[] ans = new long[1000001];
			static int[] temp;
			static long[][] count = new long[1000001][9];
			static int[] freq;
			static HashSet<Integer> pw2 = new HashSet();
			static ArrayList<Integer> ar[] = new ArrayList[9];
			public void run()

			{
				InputReader sc= new InputReader(System.in);
				PrintWriter w= new PrintWriter(System.out);
				int n = sc.nextInt();
				int peri = Integer.MAX_VALUE;
				for(int i = 1;i <= n;i++){
					peri = Math.min(n/i * 2 + i * 2 + n%i,peri);
				}
				w.println(peri);
				w.close();
			}
			static class Pair{
				int a;
				int b;
				int c;
				Pair(int a,int b,int c){
					this.a = a;
					this.b = b;
					this.c = c;
				}
			}
		}

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

import static java.lang.StrictMath.sqrt;

public class LazyGuard {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int tiles = Integer.parseInt(reader.readLine());
        int sqrt =(int) sqrt(tiles);
        int sq = sqrt*sqrt;
        int left = tiles -sq;
        int perimeter = sqrt*4;
        if(left == 0){
            System.out.print(perimeter);
        }else {
            if(left > sqrt){
                perimeter += sqrt-2;
                left -= sqrt;
            }
            perimeter += left;
            System.out.print(perimeter);
        }

    }
}

import java.util.Scanner;
public class LSG{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int w=(int)Math.sqrt(n);
int h=n/w;
System.out.println(2*(w+h)+n%w);
}
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n= sc.nextInt();
	    int sq=0,diff=0,ex=0,rem=0;
	    int mark=0,mark1=0,ans=0;
	    if(n==1)
	    ans=4;
	    else if(n==2)
	    ans=6;
	    else if(n==3)
	    ans=8;
	    else if(n>=4)
	    {
    	    sq =(int)Math.sqrt(n);
    	    diff = n-(sq*sq);
    	    ex=diff/sq;
    	    rem=diff%sq;

    	    if(ex>0)
    	    mark=((sq+1)+sq)*2;
    	    else
    	    mark=(sq+sq)*2;

    	    if(rem>0)
    	    mark1=2;

    	    if(diff==0)
    	    ans=sq*4;
    	    else
    	    {
    	        ans=mark+mark1;
    	    }
	    }
	    System.out.println(ans);

	}
}

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    Scanner in=new Scanner(System.in);
      int n=in.nextInt();
      double w1=Math.sqrt(n);

      double w= Math.ceil(Math.sqrt(n));
      double h=Math.ceil(n/(int)w1);
      int res=(int)(h+w)*2;
       double h1=(n/w1);

        System.out.println(res);

    }

}

import java.util.Scanner;

public class B859 {

    public static void main(String[] args) {
        Scanner imp = new Scanner(System.in);
        int n = imp.nextInt();
        double a = Math.sqrt(n);
        if(a*a == n){
            System.out.print((int)a*4);
        } else if(a > Math.round(a)){
            a = Math.round(a);
            System.out.print((int)Math.ceil(Math.sqrt(a*(a+1))*4));
        } else{
            a = Math.round(a);
            System.out.print((int)a*4);
        }
    }

}

import java.util.Scanner;

public class LazySecurityGuard {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int blocks = scan.nextInt();
        int squareLength = (int) Math.sqrt(blocks);
        int sqaureBlocks = squareLength * squareLength;
        int remainder = blocks - sqaureBlocks;

        int side1Blocks = remainder % squareLength;

        int side1Length;
        if (side1Blocks == squareLength) {
            side1Length = side1Blocks + 2;
        } else {
            side1Length = side1Blocks + squareLength;
        }

        remainder -= side1Blocks;
        int side2Length;
        if (remainder == squareLength) {
            side2Length = remainder + 2;
        } else {
            side2Length = remainder + squareLength;
        }

        int perimeter = squareLength + squareLength + side2Length + side1Length;

        System.out.println(perimeter);
        scan.close();
    }
}

import java.util.*;

public class test {

    public static void main(String[] args)  {
        Scanner scanner = new Scanner(System.in);
        int numberOfBlocks = scanner.nextInt();
		int circuit = -1;
        int findThatHasSquare = numberOfBlocks;
		if(Math.sqrt(findThatHasSquare)%1 == 0){
			circuit = (int) Math.sqrt(findThatHasSquare) * 4;
		}
		else{
			findThatHasSquare = --numberOfBlocks;
			while(true){
				if(Math.sqrt(findThatHasSquare)%1 == 0){
					break;
				}
				findThatHasSquare--;
			}
		}
		if(circuit == -1){
    		int sqrt = (int) Math.sqrt(findThatHasSquare);
    		circuit = sqrt * 4;
    		int restBlocks = numberOfBlocks - findThatHasSquare;
    		while(true){
    			if(restBlocks-sqrt > 0){
    				restBlocks =- sqrt;
    				circuit += 2;
    			}
    			else{
    				circuit += 2;
    				break;
    			}
    		}
		}
		System.out.println(circuit);

    }
}

/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int sq = (int)Math.sqrt(n);

		int ans = sq * 4;
		n -= sq*sq;

		if(n < sq) {
			ans += 2;
		} else {
			ans += 4;
		}

		System.out.println(ans);
	}
}

import java.util.*;
public class abcd
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
         int n= sc.nextInt();
         int val = (int)Math.sqrt(n);
         if(val*1.0==Math.sqrt(n))
         {
             System.out.println(4*val);
             System.exit(0);
         }
          for(int i = val;;i++)
          {
              if(i*i>n)
              {
                  System.out.println(i*4);
                  System.exit(0);
                }
                else if(i*(i+1)>n)
                {
                    System.out.println(2*(2*i+1));
                    System.exit(0);
                }
            }

        }
    }

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
import java.lang.Math;
public class secu
{
	public static void main(String[] args) throws IOException
	{
		int n;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int k=1;
		int a=1;
		int ans=0;
		while(a==1)
		{
			int l=k*k;
			if(l>n)
			{
				int s=(k-1)*(k-1);
				int h=n-s;
				int d=l-n;
              int g=Math.min(h,d);
              if(g==d)
              {
               	ans=l-5;
               	break;
              }
              else
              {
              	ans=s+5;
              	break;
              }
			}
			else if(l==n)
			{
              ans=4*k;
              break;
			}
			k++;
		}
		System.out.println(ans);
	}
}

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

public class Codeforces_MemSQL_round_1_LazySecurityGuard {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int x = input.nextInt();
        int closest = (int)Math.sqrt(x);
        int remain = x - closest * closest;
        int answer = 4 * closest + 2 * (remain / closest);
        if (remain % closest == 1) {
            answer += 2;
        } else if (remain % closest > 1) {
            answer += 1;
        }
        out.println(answer);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

public class PrimPrim
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int area = in.nextInt();
		int sqrt = (int)Math.sqrt((double)area);
		System.out.println(sqrt);

		int base = sqrt * 4;
		int rem = area - sqrt* sqrt;
		if(rem == 0)
		{
			base+=0;
		}
		else if(rem > sqrt)
		{
			base+=4;
		}
		else
		{
			base+=2;
		}

		System.out.println(base);
	}
}

import java.util.*;

public class B_859 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        //answer = sqrt(n)*4 if n is perfect square
        //answer = sqrt(temp)*4 + 4
        int sideL = (int) Math.sqrt(findNearestSquare(n));
        if(findNearestSquare(n)==n)
        {
            System.out.println(sideL*4);
        }
        else
        {
            int dif = n - findNearestSquare(n);
            int temp = n%2==0?4:2;
            System.out.println(sideL*4+temp);
        }

    }

    public static int findNearestSquare(int num){

//	find the square root

        int num1 = (int) Math.sqrt(num);

// if square root square’s is num… given number is a Perfect Square return the same //number

        if(num1 * num1 == num)

            return num;

        else{

// else calculate floor_square and ceil_square get absolute difference between num

// which is minimum that is the nearest square num

            int floorSquare = num1 * num1;

                return floorSquare;

        }

    }
}

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Basic {
    static final int four = 4;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = scan.nextInt();
        double value =  Math.sqrt(input);
        System.out.println("value : "+value);
        if(value % 1 == 0){
            value = value * four;
        }else{
            value = (int) value;
            int valueTemp = (int) value * (int) value;
            if((input - valueTemp) <= value){
                value = (int) value * four + 2;
            }else{
                value = (int) value * four + 4;
            }
        }
        System.out.println("value : "+value);
        }
}

//package Ladder_B;
/**
 * Created by Eesaa on 9/16/2017.
 */

import java.util.*;

public class B_859 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
       int n = in.nextInt();
        System.out.println(4*(int)(Math.ceil(Math.sqrt(n))));
    }
}

import java.util.Scanner;

public class Security {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long a=0,b=0,c=0;
       long p=(long)Math.floor(Math.sqrt(n));
        a=p;
        b=n/p;
        c=n%p;
       if(c==1)
           c=2;
           System.out.println(2*(a+b)+c);
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n= sc.nextInt();
	    int sq =(int)Math.sqrt(n);
	    int diff = n-(sq*sq);
	    int ex=diff/sq;
	    int rem=diff%sq;
	    int mark=0,mark1=0,ans=0;

	    if(ex>0)
	    mark=((sq+1)+sq)*2;
	    else
	    mark=(sq+sq)*2;

	    if(rem>0)
	    mark1=2;

	    if(diff==0)
	    ans=sq*4;
	    else
	    {
	        ans=mark+mark1;
	    }
	    System.out.println(ans);

	}
}

import java.util.Scanner;
public class Security {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long a=0,b=0;
       long p=(long)Math.floor(Math.sqrt(n));
       if((p*(p+1))<=n){
          a=p+p+1;
          b=n-(p*(p+1));
       }
       else{
           a=2*p;
           b=n-(p*p);
       }
       if(b==1)
           b=2;
           System.out.println(2*a+b);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class ProblemA {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {
		int n = sc.nextInt();
		long ans = 0, side = 0;

		for (long i = 1000; i >= 0; i--) {
			if (i * i <= n) {
				ans += i * 4;
				n -= i * 4;
				side = i;
				break;
			}
		}
		while (n > 0) {
			ans += 2;
			n -= side;
		}

		pw.println(ans);
		pw.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

	}
}

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

public class Codeforces_MemSQL_round_1_LazySecurityGuard {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int x = input.nextInt();
        int closest = (int)Math.sqrt(x);
        int remain = x - closest * closest;
        int min = Integer.MAX_VALUE;
        int side = -1;
        for (int i = 1; i <= closest; i++) {
            if (remain % i == 0) {
                int j = remain / i;
                if (min > 2 * (i + j)) {
                    min = 2 * (i + j);
                    side = Math.max(i, j);
                }
            }
        }
        int answer = 0;
        if (side != -1) {
            answer += min - 2 * Math.min(side, closest);
        }

        int regular = Integer.MAX_VALUE;
        for (int i = 1; i <= x; i++) {
            if (x % i == 0) {
                int j = x / i;
                regular = Math.min(regular, 2 * (i + j));
            }
        }
        out.println(Math.min(regular, answer + 4 * closest));
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

public class begin {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int K = in.nextInt();
        double b=0;
        int Square=0;
        for (int i = K; i >= 0; i--) {
            b = Math.sqrt(i);
            if (b - (int) b == 0) {
                Square = i;
                break;
            }
        }
        b=Math.sqrt(Square);
        if(K==Square)
        System.out.println(K*4);
        else
            if(K-Square<=b) System.out.println((int)(b*4+2));
        else System.out.println((int)(b*4+4));
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.StringTokenizer;

/**
 * Created by aarav on 9/16/17.
 */
public class A2 {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();

        /*if (n == 0) {
            System.out.println(0);
            return;
        }*/

        int minSquare = 0;
        int minPerim = 0;

        while (minSquare * minSquare < n) {
            minSquare++;
        }

        if (minSquare * minSquare == n) {
            System.out.println(minSquare * 4);
            return;
        }
        else {
            minSquare--;
            minPerim = minSquare * 4;
            //System.out.println("Initial minPerim: " + minPerim);
        }

        boolean added = false;
        int counter = 0;

        for (int i = (minSquare * minSquare); i < n; i++) {
            if (!added) {
                minPerim = minPerim + 2;
                counter++;
                added = true;
            }
            else {
                counter++;
                if (counter == minSquare) {
                    counter = 0;
                    added = false;
                }
            }
        }

        System.out.println(minPerim);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }
}

import java.util.Scanner;

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

		int square = 0;
		int justOver = 0;

		for (int i = 1; i < 1001; i++) {
			if (i * i == n) {
				square = i;
			}
			else if (i * i < n) {
				justOver = i;

			}
		}

		if (square != 0) {
			System.out.println(4 * square);
			System.exit(0);
		}
		else {
			int retVal = justOver * 4;
			int amountOver = justOver * 4;

			int blocksLeft = n - (justOver * justOver);
			for (int i = 0; i < blocksLeft; i++) {
				if (i == 0) {
					retVal += 2;

				}
				else if (i == justOver + 1) {
					retVal += 2;
				}

			}
			System.out.println(retVal);
		}

	}
}

import java.util.Scanner;
public class LSG{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int w=(int)Math.sqrt(n);
int h=n/w;
System.out.println(2*(w+h)+n%w);
}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhilash Mandaliya
 */
public class Main {
    public static void main (String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader( inputStream );
        PrintWriter out = new PrintWriter( outputStream );
        TaskB solver = new TaskB();
        solver.solve( 1, in, out );
        out.close();
    }

    static class TaskB {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long ans = Long.MAX_VALUE;
            for ( int i = ( int ) Math.ceil( n / 2 ); i > 0; i-- ) {
                int row = n / i;
                long temp = 2 * i;
                temp += 2 * row;
                if ( n % i != 0 )
                    temp += 2;
                ans = Math.min( ans, temp );
            }
            out.println( ans );
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader (InputStream st) {
            this.stream = st;
        }

        public int read () {
            if ( snumChars == - 1 )
                throw new InputMismatchException();
            if ( curChar >= snumChars ) {
                curChar = 0;
                try {
                    snumChars = stream.read( buf );
                } catch ( IOException e ) {
                    throw new InputMismatchException();
                }
                if ( snumChars <= 0 )
                    return - 1;
            }
            return buf[curChar++];
        }

        public int nextInt () {
            int c = read();
            while ( isSpaceChar( c ) ) {
                c = read();
            }
            int sgn = 1;
            if ( c == '-' ) {
                sgn = - 1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while ( ! isSpaceChar( c ) );
            return res * sgn;
        }

        public boolean isSpaceChar (int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == - 1;
        }

    }
}

/*
 * http://codeforces.com/problemset/problem/859/B
 */

/*  Basic import definitions    */
    import java.util.*;
    import java.math.BigInteger;
    import java.util.LinkedList;

/*  Basic Class definitions*/
    public class lazyGuard
    {
        public static void main(String[] args)
        {
            Scanner sc = new Scanner(System.in);

            int i , j , k;
            int T,N;
            j=0;
            T = Integer.parseInt(sc.next());
            i = (int)Math.sqrt(T);
            j = T-i*i;
            if(i*i == T)
                k = 4*i;
            else if(j<i)
            {
                k = 3*i+(j+2)+(i-j);
            }
            else
            {
                k = 3*(i)+2;
                j=j-i;
                k += j+2 + i-j;

            }
            System.out.println(k);
        }
	}

import java.util.Scanner;

public class TaskA {

    public static void main(String[] args) {
        Solver();
    }

    static void Solver() {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        if (n % 2 == 1)
            System.out.println(-(n / 2 + 1));
        else
            System.out.println(n / 2);
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n= sc.nextInt();
	    int sq=0,diff=0,ex=0,rem=0;
	    int mark=0,mark1=0,ans=0;
	    if(n==1)
	    ans=4;
	    else if(n==2)
	    ans=6;
	    else if(n==3)
	    ans=8;
	    else if(n>=4)
	    {
    	    sq =(int)Math.sqrt(n);
    	    diff = n-(sq*sq);
    	    ex=diff/sq;
    	    rem=diff%sq;

    	    if(ex>0)
    	    mark=((sq+1)+sq)*2;
    	    else
    	    mark=(sq+sq)*2;

    	    if(rem>0)
    	    mark1=2;

    	    if(diff==0)
    	    ans=sq*4;
    	    else
    	    {
    	        ans=mark+mark1;
    	    }
	    }
	    System.out.println(ans);

	}
}

import java.util.Scanner;

public class Security {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long a=0,b=0;
       long p=(long)Math.floor(Math.sqrt(n));
       if((p*(p+1))<=n){
          a=p+p+1;
          b=n-(p*(p+1));
       }
       else{
           a=2*p;
           b=n-(p*p);
       }
           System.out.println(2*a+b);
    }
}

import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        double rest = sqrt((double) n);
        if (rest - (int) (rest) == 0) out.println(n * 2);
        else {
            int sum = (int) rest * 4;
            int delta = n - (int) rest * (int) rest;
            sum+=(delta/((int)rest))*2+(delta%((int)rest));
            out.println(sum);
        }
    }
}

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

public class LazySecurityGuard {

    public static void main(String... args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out, false);

        int n = Integer.parseInt(read.readLine());
        int outerLayer = 0;
        int afterRemove = n;

        while (afterRemove > (2 * outerLayer) - 1) {
            n = afterRemove;
            outerLayer++;
            afterRemove -= ((2 * outerLayer) - 1);
        }

        int result = outerLayer * 4;
        if (n > 0 && afterRemove != 0) {
            if (afterRemove < outerLayer)
                result += 2;
            else
                result += 4;
        }

        out.println(result);

        out.flush();
        out.close();
        read.close();
    }

}