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>
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
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+ex)+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);
	
	}
}
