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 ≤ 10^6), 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]

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = 1
while a * a < n:
    a += 1

if a * (a - 1) >= n:
    print(2 * a + 2 * (a - 1))
else:
    print(4 * a)



import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())

ans=10**9

for i in range(1,2000):
    if i*i>=n:
        ans=i*4
        break
    if i*(i+1)>=n:
        ans=i*4+2
        break

print(ans)

from math import floor
n = int(input())
q = floor(n ** 0.5)
print(2 * (q + (n + q - 1) // q))


import math
N = int(input())
m = 10**18
for x in range(1, N+1):
	y = math.ceil(N/x)
	if 2*(x+y) < m:
		a, b = x, y
		m = 2*(x+y)
	x += 1
print(2*(a+b))


import math
n = int(input())
mn = 2*n+2
for i in range(n, min(4*n, n+1000)):
	s = int(math.sqrt(i))
	for j in range(s, 0, -1):
		if i%j==0:
			mn = min(mn, 2*(j + i//j))
			break
			
print(mn)


from math import floor, ceil, sqrt

n = int(input())

a = floor(sqrt(n))
b = ceil(sqrt(n))

if n == a * a: print(4 * a)
elif n <= a * b: print(2 * (a + b))
else: print(4 * b)


import math
n = int(input())


b = math.floor(math.sqrt(n))

bb = b*b

if bb == n:
    print(b*4)
else:
    left = n - bb
    if left <= b:
        print(b*4 + 2)
    else:
        print(b*4 + 4)

n=int(input())
if (n**0.5)%1==0:
    print(int(4*(n**0.5)))
else:
    count=0
    temp = int(n**0.5)+1
    temp2 = temp**2
    while temp2>=n:
        temp2-=temp
        count+=1
    print(int(2*(temp+temp-count+1)))


n = int(input())
print(next(2 * i for i in range(1000000) if (i // 2) * (i // 2 + i % 2) >= n))

import math
n=int(input())
a=int(math.sqrt(n))
ans=4*a
n=n-a*a
ans+=2*math.ceil(n/a)
print(ans)


a = int(input())
for i in range(1, 1000000):
    if i * i >= a:
        if i * (i - 1) >= a:
            print(2 * (i + i - 1));
        else:
            print(4 * i);
        break

import math


def min_perimeter(n):
    sq = math.floor(math.sqrt(n))
    rem = n - (sq ** 2)
    if rem == 0:
        return sq * 4
    elif rem <= sq:
        return (sq * 4) + 2
    else:
        return (sq * 4) + 4


n = int(input())
print(min_perimeter(n))


import math

n = int(input())

a = int(math.sqrt(n))

if a * a == n:
    print(4 * a)
elif a * (a + 1) >= n:
    print(4 * a + 2)
else:
    print(4 * (a + 1))


n = int(input())
x = int(n ** 0.5)
y = n // x

if x * y != n:
    print(2 * (x + y) + 2)
else:
    print(2 * (x + y))


from math import sqrt
n = int(input())
a = int(sqrt(n))
if (a + 1) * (a + 1) <= n:
    a += 1
left = n - a * a
b = a
c = a + left // a
ans = 2 * b + 2 * c
if b * c < n:
    ans += 2
print(ans)


import math


def main():
    n = int(input())
    length = int(math.sqrt(n))
    if length * length == n:
        print(length * 4)
    elif length * (length+1) >= n:
        print((length * 2 + 1) * 2)
    else:
        print((length+1) * 4)


def __starting_point():
    main()

__starting_point()

import sys
import math

n = [int(i) for i in sys.stdin.read().strip().split('\n')][0]

a = math.ceil(math.sqrt(n))
b = n // a
r = n - (a * b)
p = 2*a + 2*b + (2 if r else 0)

print(p)

from math import *
n=int(input())
x=n**0.5
if x==ceil(x):
    print("%d"%(4*x))
else:
    x=ceil(x)
    y=n//x
    if n!=x*y:
        y+=1
    print("%d"%(2*(x+y)))



from math import sqrt

n = int(input())

k = int(sqrt(n))

s = 4*k
if k*k < n:
	s+=2
	if k*(k+1) < n:
		s+=2
		
print(s)

n=int(input())
x=10**6
y=x
for i in range(1,n+1):
    if x+y>i+((n-1)//i+1):
        x=((n-1)//i+1)
        y=i
print(2*(x+y))


#B
n = int(input())
a = 1 #длина стороны
while a*a <= n:
    a += 1
a -= 1

p = a*4
df = n - a*a

count = df//a
p = p + 2*count

df -= count*a
if df > 0:
    p += 2

print(p)

from math import sqrt


def cal_add(x):
    return 2 if x > 0 else 0


n = int(input())
k = int(sqrt(n))
r = n - k ** 2
rs = k * 4
a = r if r <= k else r - k
b = r - a
rs += (cal_add(a) + cal_add(b))
print(rs)


n = int(input())
m = n**(1/2.0)
if(m==int(m)):
  m = int(m)
else:
  m = int(m)+1
a = m
b = m
while(a*b>=n):
  b = b-1
b = b+1
print((a+b)*2)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


n = int(input())
sq = int(n**(1 / 2))
ans = sq * 4
if n - sq**2 > sq:
    ans += 4
elif 1 <= n - sq**2 <= sq:
    ans += 2

print(ans)


from sys import stdin, stdout

n = int(stdin.readline())

l, r = 0, n + 1
while r - l > 1:
    m = (r + l) >> 1
    
    if m * m > n:
        r = m
    else:
        l = m

if n > 1:
    ans = 8 + (l - 2) * 4
else:
    ans = 4

n -= l * l
for i in range(l):
    if not i:
        if n:
            ans += 2
            n -= 1
    else:
        if n:
            n -= 1

for i in range(l):
    if not i:
        if n:
            ans += 2
            n -= 1
    else:
        if n:
            n -= 1

stdout.write(str(ans))