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.io.*;
import java.util.*;

public class J implements Runnable {

  private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

  private BufferedReader in;
  private PrintWriter out;
  private StringTokenizer tok = new StringTokenizer("");

  private void init() throws FileNotFoundException {
    Locale.setDefault(Locale.US);
    String fileName = "";
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

  }

  String readString() {
    while (!tok.hasMoreTokens()) {
      try {
        tok = new StringTokenizer(in.readLine());
      } catch (Exception e) {
        return null;
      }
    }
    return tok.nextToken();
  }

  int readInt() {
    return Integer.parseInt(readString());
  }

  long readLong() {
    return Long.parseLong(readString());
  }

  double readDouble() {
    return Double.parseDouble(readString());
  }

  int[] readIntArray(int size) {
    int[] a = new int[size];
    for (int i = 0; i < size; i++) {
      a[i] = readInt();
    }
    return a;
  }

  public static void main(String[] args) {
    //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
    new J().run();
  }

  long timeBegin, timeEnd;

  void time() {
    timeEnd = System.currentTimeMillis();
    // System.err.println("Time = " + (timeEnd - timeBegin));
  }

  @Override
  public void run() {
    try {
      timeBegin = System.currentTimeMillis();
      init();
      solve();
      out.close();
      time();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }
  }

  private int aiverson(boolean good) {
    return good ? 1 : 0;
  }

  boolean isDigit(char x) {
    return x == '0' || x == '1';
  }


  static double[][] matrix;

  private void solve() throws IOException {
    long n = readInt();
    long ans = Integer.MAX_VALUE;
    for (int x = 1; x <= n; x++) {
      if(2L * x + 2L * ((n + 1) / x) < ans){
        ans = Math.min(2L * x + 2L * ((n + x - 1) / x), ans);
      }
    }
    out.print(ans);
  }

}
