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.*;
import java.io.*;
import java.util.Scanner;
import java.math.*;
import java.lang.StringBuilder;

public class contestA
{
   private static int playerArray[] = new int[10];
   private static int computerArray[] = new int[10];
   private static int pastPlayerChoice;
   private static int pastComputerChoice;
   
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      
      int N = scan.nextInt();
      int A = (int) Math.sqrt(N);
      int B = N - A * A;
      int C = 0;
      if (B <= A && B > 0)
      {
         C = 2;
      }
      else if (B > A)
      {
         C = 4;
      }
      System.out.print(A * 4 + C);
      
      /*int playerScore = 0;
      int computerScore = 0;
      int tie = 0;
      int playerChoice = 0;
      int computerChoice = 0;
      int sum = 0;
      int count = -1;
      for (int i = 1; i < 11; i++)
      {
         System.out.printf("You: %d\tTie: %d\tComputer: %d\n\nRock, Paper, Scissors: ",
            playerScore, tie, computerScore);
         playerChoice = 3;
         while (playerChoice == 3)
         {
            String temp = scan.next().toLowerCase();
            if (temp.equals("rock") || temp.equals("r"))
            {
               playerChoice = 0;
            }
            else if (temp.equals("paper") || temp.equals("p"))
            {
               playerChoice = 1;
            }
            else if (temp.equals("scissors") || temp.equals("s"))
            {
               playerChoice = 2;
            }
         }
         computerChoice = computer(count);
         sum -= (playerArray[0] - computerArray[0]);
         update();
         if (win(playerChoice, computerChoice) == -1)
         {
            playerScore++;
            playerArray[9] = 1;
            computerArray[9] = 0;
         }
         else if (win(playerChoice, computerChoice) == 0)
         {
            tie++;
            playerArray[9] = 0;
            computerArray[9] = 0;
         }
         else
         {
            computerScore++;
            playerArray[9] = 0;
            computerArray[9] = 1;
         }
         sum += (playerArray[9] - computerArray[9]);
         if (i % 10 == 0)
         {
            System.out.print("Are you still playing? ");
            String temp = scan.next().toLowerCase();
            if (!temp.equals("no"))
            {
               i = 0;
            }
            if (sum > 0)
            {
               count++;
               count %= 1;
            }
         }
         pastPlayerChoice = playerChoice;
         pastComputerChoice = computerChoice;
      }*/
   }
   public static int computer(int x)
   {
      if (x == -1)
      {
         return (int) (Math.random() * 3);
      }
      else if (x >= 0)
      {
         if (computerArray[9] == 1)
         {
            return pastPlayerChoice;
         }
         return (3 - pastPlayerChoice - pastComputerChoice);
      }
      return 0;
   }
   public static int win(int p, int c)
   {
      if ((p > c && (p - c) < 2) || (p == 0 && c == 2))
      {
         return -1;
      }
      else if (p == c)
      {
         return 0;
      }
      else
      {
         return 1;
      }
   }
   public static void update()
   {
      for (int i = 0; i < 9; i++)
      {
         playerArray[i] = playerArray[i + 1];
         computerArray[i] = computerArray[i + 1];
      }
   }
}