using System;
using System.IO;
using System.Text;

namespace Lazy_Security_Guard
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();

            int min = int.MaxValue;
            for (int i = 1; i <= n; i++)
            {
                int k = (n + i - 1)/i;
                int p = 2*(i + k);
                min = Math.Min(min, p);
            }

            writer.WriteLine(min);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;

namespace Achill
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine()), sqr = (int)Math.Sqrt(N);
            Console.WriteLine(2 * Math.Ceiling(2 * Math.Sqrt(N)));
        }
    }
}

using System;

namespace Achill
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(2 * Math.Ceiling(2 * Math.Sqrt(N)));
        }
    }
}

using System;

namespace Achill
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine()), sqr = (int)Math.Sqrt(N);
            Console.WriteLine(4 * sqr + (N - (sqr * sqr) == 0 ? 0 : N - (sqr * sqr) <= sqr ? 2 : 4));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string  r=Console .ReadLine() ;
              int  t=int.Parse (r);
            //a=4
             double  a=Math.Ceiling( Math.Sqrt(t));

             double f = a * a - t;
             double d = a - Math.Floor(f / a);
            Console.WriteLine(2*(a+d));

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int result;
            int n = int.Parse(Console.ReadLine());
            int newNumber = (int)Math.Ceiling(Math.Sqrt(n));
            int fullLineNumber = n / newNumber;
            int leftBlocksInLine = n % newNumber;
            if (newNumber * newNumber == n)
                result = newNumber * 4;
            else if (leftBlocksInLine == 0) result = newNumber * 2 + fullLineNumber * 2;
            else result = newNumber * 2 + fullLineNumber * 2 + 2;
            Console.WriteLine(result);
        }
    }
}

using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sqrt = (int)Math.Sqrt(n);
            n -= sqrt * sqrt;
            int rez = sqrt*4+(n==0?0:n<=sqrt?2:4);
            Console.WriteLine(rez);
        }
    }
}

using System;
using System.Globalization;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace Olymp
{
  public class ProblemSolver
  {
    private readonly Tokenizer input;

    public void Solve()
    {
      var n = input.ReadInt();
      var k = (int)Sqrt(n);
      var m = n - k * k;
      var ans = 4 * k;
      if (m != 0)
      {
        if (m <= k)
          ans += 2;
        else
          ans += 4;
      }
      Write(ans);
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private readonly TextReader reader;

    public string ReadToEnd()
    {
      return reader.ReadToEnd();
    }

    public int ReadInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      var isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = reader.Read();
        if (c == -1)
          throw new EndOfStreamException("Digit expected, but end of stream occurs");
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException($"Digit expected, but was: '{(char)c}'");
      var result = (char)c - '0';
      c = reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException($"Digit expected, but was: '{(char)c}'");
        result = result * 10 + (char)c - '0';
        c = reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long ReadLong()
    {
      return long.Parse(ReadToken());
    }

    public double ReadDouble()
    {
      return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      var a = new int[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadInt();
      return a;
    }

    public (int, int) Read2Int() =>
      (ReadInt(), ReadInt());

    public (int, int, int) Read3Int() =>
      (ReadInt(), ReadInt(), ReadInt());

    public (int, int, int, int) Read4Int() =>
      (ReadInt(), ReadInt(), ReadInt(), ReadInt());

    public long[] ReadLongArray(int n)
    {
      var a = new long[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      var a = new double[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadDouble();
      return a;
    }

    public string ReadToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      var c = reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  internal class Program
  {
    public static void Main()
    {
      var solver = new ProblemSolver(In);
      solver.Solve();
    }
  }

  #endregion
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Lazy_guard859B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, helper, ans;
            double d;
            N = int.Parse(Console.ReadLine());
            //double doubleVal = System.Convert.ToDouble(input);
            d = Math.Sqrt(N);
            // helper = (int) Math.Round(d);
            helper = Convert.ToInt32(Math.Round(d));

            if (helper > d || helper == d) ans = 4 * helper;
            else ans = (4 * helper) + 2;
            Console.WriteLine(ans);
           // Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    class B
    {
        static void Main(string[] args)
        {
           int n = int.Parse(Console.ReadLine());
           Console.WriteLine(2*Math.Ceiling(2*Math.Sqrt(n))) ;
        }
    }
}

	using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int prev = 8;

			if (n <= 0) { Console.WriteLine(0); return; }
            if (n == 1) { Console.WriteLine(4); return;}
			if (n == 2) { Console.WriteLine(6); return; }
			if (n == 3) { Console.WriteLine(8); return; }
			if (n == 4) { Console.WriteLine(8); return; }

            for (int i = 5; i <= n; i ++)
            {
                int c = (int)Math.Sqrt(i);

                if (i == c * c + 1)
                {
                    prev += 2;
                    continue;
                }

                if (i == c * (c + 1) + 1)
                {
                    prev += 2;
                    continue;
                }

            }

            Console.WriteLine(prev);
        }
    }

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int t = (int)Math.Sqrt(n);
            if (Math.Sqrt(n) % 1 == 0) Console.WriteLine(4 * t);
            else if (n <= t * (t + 1)) Console.WriteLine(4 * t + 2);
            else Console.WriteLine(4 * (t + 1));
        }
    }
}

using System;
// you can also use other imports, for example:
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class HelloWorld {

	public static void Main(string[] args)
	{
		int n = Convert.ToInt32(Console.ReadLine());

		//var ceiling = Math.Ceiling(Math.Sqrt(n));
		var floor = Math.Floor(Math.Sqrt(n));

		var i = 1;
		while (i * floor < n)
		{
			i++;
		}

		Console.WriteLine(i*2 + floor * 2);
	}

}

// Problem: 859B - Lazy Security Guard
// Author: Gusztav Szmolik

using System;

class LazySecurityGuard
    {
    static int Main ()
        {
        string[] words = ReadSplitLine (1);
        if (words == null)
            return -1;
        uint n;
        if (!UInt32.TryParse (words[0], out n))
            return -1;
        if (n < 1 || n > 1000000)
            return -1;
        ushort a = 1;
        ushort aNext = 2;
        while (aNext*aNext <= n)
            {
            a = aNext;
            aNext++;
            }
        ushort r = Convert.ToUInt16 (n-a*a);
        ushort ans = Convert.ToUInt16 (r == 0 ? 4*a : (r > a ? 4*a+4 : 4*a+2));
        Console.WriteLine (ans);
        return 0;
        }

    static string[] ReadSplitLine (uint numWordNeed)
        {
        string line = Console.ReadLine ();
        if (line == null)
            return null;
        char[] delims = new char[2] {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        return (words.Length == numWordNeed ? words : null);
        }
    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.Lazy_Security_Guard
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = Convert.ToInt32(Console.ReadLine());
            int x1 = Convert.ToInt32(Math.Sqrt(x));
            int e = x - (x1 * x1);
            if ((((x1 + 1) * (x1 + 1) - (x1 * x1)) / 2) + 1 > e) Console.WriteLine((x1 * 4) + (2*(e>0?1:0)));
            else
            {
                Console.WriteLine((x1 * 4) + 4);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace problem2
{
    class Program
    {
        static void Main(string[] args)
        {
            double num = double.Parse(Console.ReadLine());
            double ans = Math.Sqrt(num);
            double round = Math.Ceiling(ans);
            int length = 0;
            double output = 0;
            if (num == 1)
            {
                output = 4;
            }
            else
            {
                for (int i = 1; i < num; i++)
                {
                    if (round* i >= num)
                    {
                        length = i;
                        break;
                    }
                }
                output = (length * 2) + (round * 2);
            }

            Console.WriteLine(output);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MemSQL3R1P2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int Limit = (int)Math.Ceiling(Math.Sqrt(N));
            var XY = Get(Limit, N);
            Console.WriteLine(2 * (XY.Item1 + XY.Item2));
        }

        static Tuple<int,int> Get(int Limit, int N)
        {
            for (int i = 1; i <= Limit; i++)
                for (int j = 1; j <= Limit; j++)
                    if (i * j >= N)
                        return Tuple.Create(i, j);

            return null;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int i = 0;
            for (i = 1; i <= 1000; i++)
            {
                if (i * i == n) break;
                if (i * i > n)
                {
                    i--;
                    break;
                }
            }
            if (i * i == n)
            {
                Console.WriteLine(i*4);
            }
            else
            {
                int x = n - i * i;
                int p = i * 4;
                if (x > i) p += 4;
                else p += 2;
                Console.WriteLine(p);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace qwerty
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 n = Int32.Parse(Console.ReadLine());

            int a = (int)(Math.Sqrt(n));
            int b = n / a;
            int ost = n - a * b;
            if (ost == 0)
                Console.WriteLine(2 * (a + b));
            else
                Console.WriteLine(2 * (a + b+1));

        }
    }
}

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    ReadData re;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        re = new ReadData();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = re.i();
        for(int i=0;i<1000000;i++){
            if(i*i >= N){
                sb.Append(4*i+"\n");
                return;
            }
            if(i*(i+1) >= N){
                sb.Append((4*i+2)+"\n");
                return;
            }
        }
    }
}
class ReadData{
    string[] str;
    int counter;
    public ReadData(){
        counter = 0;
    }
    public string s(){
        if(counter == 0){
            str = Console.ReadLine().Split(' ');
            counter = str.Length;
        }
        counter--;
        return str[str.Length-counter-1];
    }
    public int i(){
        return int.Parse(s());
    }
    public long l(){
        return long.Parse(s());
    }
    public double d(){
        return double.Parse(s());
    }
    public int[] ia(int N){
        int[] ans = new int[N];
        for(int j=0;j<N;j++){
            ans[j] = i();
        }
        return ans;
    }
    public int[] ia(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        int[] ans = new int[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = int.Parse(str[j]);
        }
        return ans;
    }
    public long[] la(int N){
        long[] ans = new long[N];
        for(int j=0;j<N;j++){
            ans[j] = l();
        }
        return ans;
    }
    public long[] la(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        long[] ans = new long[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = long.Parse(str[j]);
        }
        return ans;
    }
    public double[] da(int N){
        double[] ans = new double[N];
        for(int j=0;j<N;j++){
            ans[j] = d();
        }
        return ans;
    }
    public double[] da(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        double[] ans = new double[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = double.Parse(str[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int[] f,int[] t){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<f.Length;j++){
            ans[f[j]].Add(t[j]);
            ans[t[j]].Add(f[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int M){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
    public List<int>[] g(){
        int N = i();
        int M = i();
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
}
public static class Define{
    public const long mod = 1000000007;
}
public static class Debug{
    public static void Print(double[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(long[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(int[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			//string input2 = Console.ReadLine();

			//string input3 = Console.ReadLine();
			//string input4 = Console.ReadLine();

			//var inputs1 = input1.Split(new[] {' ', '}', '{', ','}, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
			//var inputs3 = input3.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs4 = input4.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();

			long n = long.Parse(input1);

			double sqrt = Math.Sqrt(n);
			long longSqrt = (long)sqrt;

			long start = sqrt - longSqrt > 0 ? longSqrt + 1 : longSqrt;

			if (start * (start - 1) >= n)
			{
				Console.WriteLine(2 * start + 2 * (start - 1));
			}
			else
			{
				Console.WriteLine(4 * start);
			}
		}

		static int ParseSize(string size)
		{
			switch (size)
			{
				case "S":
					return 0;
				case "M":
					return 1;
				case "L":
					return 2;
				case "XL":
					return 3;
				case "XXL":
					return 4;
				default:
					throw new NotImplementedException();
			}
		}

		static string IntToSize(int size)
		{
			switch (size)
			{
				case 0:
					return "S";
				case 1:
					return "M";
				case 2:
					return "L";
				case 3:
					return "XL";
				case 4:
					return "XXL";
				default:
					throw new NotImplementedException();
			}
		}

		static IList<int> GetListForSize(int size)
		{
			var list = new List<int>();
			switch (size)
			{
				case 0:
					list.AddRange(new[] { 1, 2, 3, 4 });
					break;
				case 1:
					list.AddRange(new[] { 2, 0, 3, 4 });
					break;
				case 2:
					list.AddRange(new[] { 3, 1, 4, 0 });
					break;
				case 3:
					list.AddRange(new[] { 4, 2, 1, 0 });
					break;
				case 4:
					list.AddRange(new[] { 3, 2, 1, 0 });
					break;
			}

			return list;
		}

		static long Factorial(long a)
		{
			return a > 1 ? a * Factorial(a - 1) : 1;
		}
	}
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt64();
            var m = (long) Math.Sqrt(n);
            var total = m * m;
            var d = n - total;
            var result = 3L * m;

            if (d != 0) {
                while (d / m > 0) {
                    result += 2L;
                    d -= m;
                }
                if (d > 0) {
                    result += 2L + d + (m - d);
                }
                else {
                    result += m;
                }
            }
            else {
                result += m;
            }

            sw.WriteLine(result);
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1B
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = int.Parse(Console.ReadLine());
            //b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int g = (int)Math.Floor(Math.Sqrt(a));
            double s = (double)g * 4;
            double d = a - (g*g);
            double x = d/g;
            d = (Math.Ceiling(x))*2;
            s += d;
            Console.WriteLine(s);

        }

    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            double n = double.Parse(Console.ReadLine());

            double k = Math.Ceiling(Math.Sqrt(n));

            double s = Math.Floor(n / k);

            double res = 0;

            if ( n-k*s!=0       )
            {
                res = (k * 2 + s * 2) + 2;
            }
            else
            {
                res = (k * 2 + s * 2);
            }

            Console.WriteLine(res);

              // while (Console.ReadKey().Key != ConsoleKey.Enter) ;

        }
    }
}

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ConsoleApplication1.CodeForces
{
    static class _4032123
    {
        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);

        class Node
        {
            public int D { get; set; }
            public int F { get; set; }
            public int T { get; set; }
            public long C { get; set; }
        }
        static void Main(String[] args)
        {
            var n = int.Parse(Console.ReadLine().TrimEnd());
            long pMin = long.MaxValue;
            if (n == 1)
            {
                pMin = 4;
            }
            for(var i = 1; i < n; i++)
            {
                double x = i;
                long y = (long)Math.Ceiling(n / x);
                long tr = 2 * (long)x + 2 * y;
                pMin = Math.Min(pMin, tr);
            }
            writer.WriteLine(pMin);
            writer.Flush();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();

        int m = 1;
        while (m * m <= n)
            m++;
        m--;

        int ans = 4 * m;
        if (n - m * m > 0)
            ans += 2;
        if (n - m * m > m)
            ans += 2;

        Write(ans);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}

using System;

namespace MemSQL_09_17_2017_Q2
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int sqrt = (int)Math.Round(Math.Sqrt(Convert.ToDouble(input)), 0);
            int result = 0;

            if(input <= sqrt * sqrt)
            {
                result = sqrt * 4;
            }
            else if (input > sqrt * sqrt)
            {
                result = (sqrt + (sqrt + 1)) * 2;
            }

            Console.WriteLine(result);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class B
    {
        private static ThreadStart s_threadStart = new B().Go;

        private void Go()
        {
            int N = GetInt();
            int s = (int)Math.Ceiling(Math.Sqrt(N));
            int ans = s;
            while (ans * s >= N)
            {
                ans--;
            }

            Wl(2 * (s + ans + 1));
        }

        #region Template

        private static StringBuilder output = new StringBuilder();

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            output.Length = 0;
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            Console.Write(output);
            timer.Stop();
            Console.Error.WriteLine(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            do
            {
                while (ioEnum == null || !ioEnum.MoveNext())
                {
                    ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
                }
            } while (string.IsNullOrEmpty(ioEnum.Current));

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            W(o);
            output.Append(Console.Out.NewLine);
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            W(enumerable);
            output.Append(Console.Out.NewLine);
        }

        private static void W<T>(T o)
        {
            if (o is double)
            {
                Wd((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wd((o as float?).Value, "");
            }
            else
                output.Append(o.ToString());
        }

        private static void W<T>(IEnumerable<T> enumerable)
        {
            W(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wd(double d, string format)
        {
            W(d.ToString(format, CultureInfo.InvariantCulture));
        }

        #endregion
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace qwerty
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 n = Int32.Parse(Console.ReadLine());

            int k = (int)(Math.Sqrt(n));

            int ost = n % k;

            int res = 0;
            res += 4 * k;
            if (ost == 0)
                Console.WriteLine(res);
            else
            {
                res += 2;
                Console.WriteLine(res);
            }

        }
    }
}

using System;

namespace Achill
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine()), sqr = (int)Math.Sqrt(N);
            Console.WriteLine(4 * sqr + (N % (sqr * sqr) == 0 ? 0 : N % (sqr * sqr) <= sqr ? 2 : 4));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int result;
            int n = int.Parse(Console.ReadLine());
            int newNumber = (int)Math.Ceiling(Math.Sqrt(n));
            int fullLineNumber = n / newNumber;
            //int leftBlocksInLine = n % newNumber;
            if (newNumber*newNumber == n)
                result = newNumber * 4;
            else result = newNumber * 2 + fullLineNumber * 2 + 2;
            Console.WriteLine(result);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int result;
            int n = int.Parse(Console.ReadLine());
            int newNumber = (int)Math.Ceiling(Math.Sqrt(n));
            int fullLineNumber = n / newNumber;
            int leftBlocksInLine = n % newNumber;
            //int leftBlocksInLine = n % newNumber;
            if (newNumber * newNumber == n)
                result = newNumber * 4;
            else if (leftBlocksInLine == 0) result = newNumber * fullLineNumber;
            else result = newNumber * 2 + fullLineNumber * 2 + 2;
            Console.WriteLine(result);
        }
    }
}

using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sqrt = (int)Math.Sqrt(n);
            n -= sqrt * sqrt;
            int rez = sqrt*4+(n==0?0:n<sqrt?2:4);
            Console.WriteLine(rez);
        }
    }
}

	using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int prev = 8;

            if (n == 1) { Console.WriteLine(4); return;}
			if (n == 2) { Console.WriteLine(6); return; }
			if (n == 3) { Console.WriteLine(8); return; }
			if (n == 4) { Console.WriteLine(8); return; }

            for (int i = 5; i <= n; i ++)
            {
                int c = (int)Math.Sqrt(i);

                if (c * c == i)
                    continue;

                if (i == c * c + 1)
                {
                    prev += 2;
                    continue;
                }

                if(i > c * c + 1 && i < c * (c + 1))
                {
                    continue;
                }

                if (i == c * (c + 1))
                {
                    prev += 2;
                    continue;
                }

            }

            Console.WriteLine(prev);
        }
    }

	using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int prev = 8;

			if (n <= 0) { Console.WriteLine(0); return; }
            if (n == 1) { Console.WriteLine(4); return;}
			if (n == 2) { Console.WriteLine(6); return; }
			if (n == 3) { Console.WriteLine(8); return; }
			if (n == 4) { Console.WriteLine(8); return; }

            for (int i = 5; i <= n; i ++)
            {
                int c = (int)Math.Sqrt(i);

                if (i == c * c + 1)
                {
                    prev += 2;
                    continue;
                }

                if (i == c * (c + 1))
                {
                    prev += 2;
                    continue;
                }

            }

            Console.WriteLine(prev);
        }
    }

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int t = Convert.ToInt32(Math.Sqrt(n));
            if (n <= t * (t + 1)) Console.WriteLine(4 * t + 2);
            else Console.WriteLine(4 * (t + 1));
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int t = Convert.ToInt32(Math.Sqrt(n));
            if (Math.Sqrt(n) % 1 == 0) Console.WriteLine(4 * t);
            else if (n <= t * (t + 1)) Console.WriteLine(4 * t + 2);
            else Console.WriteLine(4 * (t + 1));
        }
    }
}