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>
def binarysearch(sequence, value):
    lo, hi ,mid= 0, 1000,0
    if value==1000000:
        return 1000000
    while lo < hi:

        mid=(lo+hi)//2

        if sequence[mid]<=value and sequence[mid+1]>value:
            return a[mid]
        elif sequence[mid]>value:
            hi=mid
        elif sequence[mid]<value:
            lo=mid

    return a[mid]
n=int(input())
a=[i**2 for i in range(1,1001)]

used=binarysearch(a,n)
left=n-used
side=int(used**(0.5))
ans=4*side
if  left and left>side:
    print(ans+4)
elif left:
    print(ans+2)
else:
    print(ans)
