Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. Your friend is quite lazy and would like your help to find the shortest possible route that meets the requirements. The city is laid out in a square grid pattern, and is large enough that for the sake of the problem it can be considered infinite.

Input

Input will consist of a single integer N (1 ≤ N ≤ 106), the number of city blocks that must be enclosed by the route.

Output

Print the minimum perimeter that can be achieved.

Examples

Input

4


Output

8


Input

11


Output

14


Input

22


Output

20

Note

Here are some possible shapes for the examples:

<image>

import java.util.Scanner;

public class CF859B 
{
	public static void main(String[] args)
	{
		CF859B task = new CF859B();
		Problem solver = task.new Problem();
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		System.out.println(solver.solve(n));
	}
	
	public class Problem
	{
		public Problem()
		{
			
		}
		
		private int maxi(int a,int b)
		{
			int ans = 0;
			
			if(a > b)
				ans = a;
			else
				ans = b;
			
			return ans;
		}
		
		private int[] getSides(int n)
		{
			int[] ans = new int[2];
			
			double sqrtnd = Math.sqrt((double)n);
			int sqrtni = (int)sqrtnd;
			
			if((sqrtnd - sqrtni) > 0)
			{
				ans[0] = sqrtni;
				for(int i = sqrtni,mul = sqrtni * i; mul < n; i++,mul = sqrtni * i)
				{	
					ans[1] = i;
				}
			}
			else
			{
				ans[0] = sqrtni;
				ans[1] = sqrtni;
			}
			
			return ans;
		}
		
		private int getCorners(int y,int x)
		{
			int ans = 0;
			
			if(y > 1 && x > 1)
				ans = 4;
			else
			if(y > 1 || x > 1)
				ans = 2;
			else
				ans = 1;
			
			return ans;
		}
		
		private int getCornersEdges(int corners)
		{
			int ans = 0;
			
			if(corners >= 4)
				ans = corners * 2;
			else
			if(corners >= 2)
				ans = corners * 3;
			else
			if(corners >= 1)
				ans = corners * 4;
			
			return ans;
		}
		
		public int getEdges(int y,int x)
		{
			int ans = 0;
			
			if(y >= 2 && x >= 2)
			{
				ans = 2 * (x - 2);
				ans = ans + (2 * (y - 2)); 	
			}
			else
			if(y >= 1 || x >= 1)
			{
				ans = maxi(ans,2 * (x - 2));
				ans = maxi(ans,2 * (y - 2));
			}
			
			return ans;
		}
		
		private int getPerimeter(int y,int x)
		{
			int ans = 0;
	
			ans = getCornersEdges(getCorners(y, x)) + getEdges(y, x);
			
			return ans;
		}
		
		public int solve(int n)
		{
			int ans = 0;
			
			int[] sides = getSides(n);
			ans = getPerimeter(sides[0], sides[1]);
			int left = (n - (sides[0] * sides[1]));
			if(left > 0)
				ans = ans + getPerimeter(1, left) - (2 * left);
			
			return ans;
		}
	}
}
