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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B {

	static long sq(long x) {
		return x * x;
	}

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		long n = sc.nextLong(), l;
		for (l = 1; l <= 1000; l++)
			if (sq(l) >= n)
				break;
		if (sq(l) == n) {
			out.println(l << 2);
			out.flush();
			out.close();
			return;
		}
		long h;
		for (h = 1000; h >= 1; h--)
			if (sq(h) <= n)
				break;
		long lh = 0, temp = n;
		while (temp - l >= 0) {
			temp -= l;
			lh++;
		}
		long hh = 0;
		while (n - h >= 0) {
			n -= h;
			hh++;
		}
		if(n > 0)
			hh++;
		if(temp > 0)
			lh++;
		out.println(Math.min((lh + l) << 1, (hh + h) << 1));
		out.flush();
		out.close();
	}

	static class MyScanner {

		BufferedReader br;
		StringTokenizer st;

		MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

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

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

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

		boolean ready() throws IOException {
			return br.ready();
		}
	}
}
