#include <stdio.h>
#include <math.h>

int main()
{
    int N,sqrt_N;
    double avg;
    scanf("%d",&N);
    sqrt_N=sqrt(N);
    if(sqrt_N*sqrt_N==N)
        printf("%d",sqrt_N*4);
    else
    {
        avg=((sqrt_N)*(sqrt_N)+(sqrt_N+1)*(sqrt_N+1))/2.0;
        if(avg>N)
            printf("%d",((sqrt_N+1)*2)+(sqrt_N*2));
        else
            printf("%d",(sqrt_N+1)*4);
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{int n,d;
float b,a;
scanf("%f",&a);
b=sqrt(a);
d=b;
if(b==d)
 {
     printf("%d",d*4);}

else {
n=((d+1)*(d+1)-d*d)/2;
        if(d*d+n>=a)
    printf("%d",d*4+2);
else
   printf("%d",(d+1)*4);
   }
}

#include <stdio.h>
#include <math.h>

int main(){
    float h;
    int n;
    scanf("%d",&n);
    printf("%.0f",2*ceil(2*sqrt(n)));

}

#include <stdio.h>
#include <math.h>

int main()
{
    int a,p;
    scanf("%d",&a);
    int i,j;
    for(i=1; ;i++)
        for(j=1;j<=i;j++)
        {
            if(i*j>=a)
            {
             float x=4*sqrt(i*j);
             p=x;
             if(x!=p)
                p++;
             printf("%d",p);
             return;
            }
        }
    return 0;
}

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>

#define MAX 1000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    long long n, i, j, k, x, y, z, res;

    while (scanf("%lld", &n) != EOF){
        res = 1LL << 60;
        for (i = 1; i <= n; i++){
            x = n / i, y = n % i;
            if (y == 0){
                z = 2 * (x + i);
                if (z < res) res = z;
            }
            else{
                z = 2 * (x + i) + 2;
                if (z < res) res = z;
            }
        }

        printf("%lld\n", res);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int gcd(int a,int b)
{
	if(b==0)
		return a;
	gcd(b,a%b);
}

int main()
{
	int n;
	scanf("%d",&n);
	int p=sqrt(n);
	int q=p*4;

	int r=n-(p*p);
	while(r>=p)
	{
		r-=p;
		q+=2;
	}
	if(r>0)
		q+=2;
	printf("%d\n",q);

	return 0;

}

#include<stdio.h>
int main()
{ int n,i,x,t,r;
 scanf("%d",&n);
t=2*(n+1);
   for(i=1;i<n;i++)
  {
if (n%i!=0)
r=2+i;
else
r=i;
 x=2*(n/i)+i+r;
 if (x<t)
  t=x;  }
printf("%d",t);

return 0;
}

#include<stdio.h>

long long isquare(long long n)
{
    long long i;
    if(n==1)return 1;
    else if(n==4)return 2;
    else if(n==9)return 3;
    else if(n==16)return 4;
    else if(n==25)return 5;
    else if(n==36)return 6;
    else if(n==49)return 7;
    else if(n==64)return 8;
    else if(n==81)return 9;
    for(i=10;i<=n/10;i++)
        if(i*i==n)
        return i;
    return 0;
}
main()
{
    long long n,ans,min,a,b,val,n1;
    scanf("%lld",&n);
    n1=n;
    if(isquare(n))
     {
         ans=4*isquare(n);
         printf("%lld",ans);
         return 0;
     }
    else
    {
       while(!isquare(n))
            n++;
       val=isquare(n);
       a=4*isquare(n);
       b=(val+(val-1))*2;
       min=a<b?a:b;
       if((val*(val-1))<n1)
       printf("%lld",a);
       else printf("%lld",min);
    }
}

#include<stdio.h>
#include<math.h>
int main()
{
    int a,n;
    scanf("%d",&n);
    a = 2*ceil(2*sqrt(n));
    printf("%d",a);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,i,j,k;
    double x,y;
    scanf("%d",&a);
    y=a;
    x=sqrt(y);
    b=x;

    c=(4*b);

    a=a-(b*b);

    c+=(2*(a/b));

    if(a%b!=0)
        c+=2;
    printf("%d\n",c);
    return 0;
}

#include<stdio.h>

int main()
{
 long long N;
 long long squares[1005];
 long long maxsquare;
 long long maxlines;
 long long remainder;
 long long squareside;
 long long perimeter;
 int i;
 for(i=0;i<=1000;i++) squares[i]=i*i;

 scanf("%lld",&N);
 for(i=1;i<=1000;i++)
 {
  maxsquare=squares[i];
  squareside=i;
  if(squares[i+1]>N) break;
 }

 remainder=N-maxsquare;
 maxlines=remainder/squareside;
 remainder=remainder-maxlines*squareside;

 perimeter=4*squareside;
 if(maxlines>0) perimeter+= 2*maxlines;
 if(remainder>0) perimeter+=2;
 printf("%lld\n",perimeter);
 return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
int n;
scanf("%d",&n);
 int k=(int)sqrt(n);
//int k=
//printf("%d",m);
if(n==k*k)
{
  printf("%d",4*k);
}
else if(n-(k*k)<=k)
{
  printf("%d",3*k+2+n-(k*k)+k-(n-k*k));
}
else if(n-(k*k)>k)
{
  printf("%d",3*k+4+n-(k*(k+1))+k-(n-k*(k+1)));
}

}

#include <stdio.h>
#include <math.h>

int main()
{
    int a,c,d,e,f,g;
    double b;

    d = 4;
    f = 2;
    scanf("%d", &a);
    b = sqrt(a);
    c = sqrt(a);
    e = c*c;
    g = c*d;
    if(b-c == 0)
    {
        printf("%d", g);
    }
    else if(a-e <= c)
    {
        printf("%d", g+f);
    }
    else
    {
        printf("%d", g+d);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,i,k,d=1,a;
    scanf("%lld",&n);
    if(n==1)
    printf("4");
    else
        if(n==2)
        printf("6");
    else
    {
    for(i=1;i<n;i++)
    {
        if(i*i>=n)
        {
          k=i;
          break;
        }
    }
    for(i=k;i>=0;i--)
    {
        if(k*i<n)
        {
            d=i+1;
            break;
        }
    }
    a=2*k+2*d;
    printf("%lld",a);
    }
    return 0;
}

#include <stdio.h>
int x,n,k,t;

int main(void) {
    scanf("%d",&t);
    n=sqrt(t);
    if(n*n==t){
        printf("%d",4*n);
    }else{
        n++;
        k=2*(t/n)+2*n;
        if(t%n!=0){
            k=k+2;
        }
        printf("%d",k);
    }
	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,i,j,k;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        if(i*i>n)
        {
            i--;break;
        }
    }
    k=n-i*i;if(n!=2){
    if(k!=0){
    if(k<=i)
    {
        printf("%lld",i*4+2);
    }
    else
    {
        printf("%lld",i*4+4);
    }}
    else
        printf("%lld",4*i);}
        else
            printf("6");
     return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	double a=sqrt(n);
	int b=ceil(a);
	int count=0;
	while(n>0)
	{
		n-=b;
		count++;
	}
	printf("%d\n",2*b+2*count);
	return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
    int N,k,n,ans;
    scanf("%i",&N);
    n=sqrt(N)+.5;
    k=N-n*n;
    ans = 4*n+2*((k+n-1)/n);
    //printf("%i\nans=%i\tk=%i",n,ans,k);
    printf("%i",ans);
    //system("pause");
    return 0;
}

// A H × W rectangle has a perimeter of 2·(H + W). The constraints of the problem were low enough that one could loop through every possible value of H and find the smallest corresponding W such that H·W ≥ N. We can show that the best rectangle will always have . Consider what happens if W ≥ H + 2. Then (W - 1)·(H + 1) = W·H + (W - H) - 1 ≥ W·H + (2) - 1 = W·H + 1. In other words, the (W - 1) × (H + 1) rectangle has greater area than the W × H rectangle, but the same perimeter.

// A direct solution therefore sets w=sqrt(N)  and H = ⌈ N / W⌉.
#include<stdio.h>
#include<math.h>
int main()
{
    long long int N;
    scanf("%lld",&N);
    long long int H,W;
    H=sqrt(N);
    W=N/H;
    // printf("%lld %lld",H,W);
    if(H*W>=N)
    {
        printf("%lld",2*(H+W));
    }
    else
    {
        printf("%lld",2*(H+W+1));
    }

}

#include <stdio.h>

int minperi(int a)
{
	for(int i=1;;i++)
	{
		if(i*(i-1)>=a)
			return 4*i-2;
		else if(i*i>=a)
			return 4*i;
	}
}

int main()
{
	int n;
	scanf("%d",&n);
	printf("%d",minperi(n));
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
 int n;
 int res;
 scanf("%d",&n);
 res= 2*ceil((2*sqrt(n)));
 printf("%d",res);
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int blocks,i=0;
    scanf("%d", &blocks);
    while(i*i<=blocks)
    {
        ++i;
    }
    --i;
    int szeleszama=4*i;//i*i s negyzet oldala
    if(blocks-i*i>i)
    {
        szeleszama+=4;
    }
    else if(blocks==i*i)
    {
        //nothing really xd
    }
    else
    {
        szeleszama+=2;
    }
    printf("%d",szeleszama);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
   int a,b,n,p;
   scanf("%d",&n);
   a=ceil(sqrt(n));
   if(n%a==0){
   b=ceil(n/a);}
   else{b=ceil(n/a)+1;}
   printf("%d",2*(a+b));
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main()
{
	int n, d;
	scanf("%d",&n);

	d = sqrt(n);

	int form;
	form = n - d * d;

	int hex;
	hex = d * 4;

	if(form == 0)
	{
		printf("%d\n", hex);
	}

	else if(form != 0)
	{
		if(form > d)
		{
			printf("%d\n", hex + 4);
		}

		else
		{
			printf("%d\n", hex + 2);
		}
	}

	return 0;
}

#include <stdio.h>
#include <math.h>

int main(){

    long x;
    scanf("%ld", &x);
    long a = sqrt(x);
    long perimeter = 0;

    if(a * a >= x) perimeter = 4 * a;
    else if(a * (a + 1) >= x) perimeter = 4 * a + 2;
    else if((a + 1) * (a + 1) >= x) perimeter = 4 * a + 4;

    printf("%ld\n", perimeter);

    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	int n,x,m,y,ans,z;
	scanf("%d",&n);
	m=floor(sqrt(n));
	x=(n-(m*m))/m;
	y=(n-(m*m))%m;
	ans=(4*m);
	if((x==0&&y>0)||(x==1&&y==0))
	    ans+=2;
	else if(x==0&&y==0){}
	else
	    ans+=4;
	printf("%d",ans);
}

#include <stdio.h>
#include <math.h>
double hj(int n)
{
    return ceil(2*sqrt(n));
}
int main()
{
    int n;
    scanf("%d",&n);
    printf("%.0f",2*hj(n));

}

#include<stdio.h>
#include<math.h>
int main()
{
	int N,w,h;
	scanf("%d",&N);
	w=sqrt(N);
	h=N/w;
	if(w*h==N)
	printf("%d",2*(w+h));
	if(w*h!=N){

	printf("%d",2*(w+h)+2);
}
 }

#include<stdio.h>

int main(){
	int n, a, b, best=100000000;
	scanf("%d", &n);
	for(a=1;a<=n;++a){
		b=n/a+(n%a!=0);
		if(2*(a+b)<best) best=2*(a+b);
	}
	printf("%d\n", best);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

/*Lazy Security Guard*/
int main()
{
    int input_num, perimeter,temp,count = 0;
    scanf("%d",&input_num);
    temp = input_num;
    if(input_num == 1)
    {
        perimeter = 4;
    }
    else if(input_num <= 0)
    {
        perimeter = 0;
    }
    else
    {
        while(input_num >= (count * count))
        {
            count++;
        }
        count--;
        /*
        while(count != temp)
        {
            count++;
            temp = input_num / count;
        }
        */
        /*
        while(temp != 1)
        {
            temp /= 2;
            count++;
        }
        */
        perimeter = count * 4;
        temp = input_num - (count*count);
        while(temp > 0)
        {
            temp = temp - count;
            perimeter = perimeter + 2;
        }
    }
    printf("%d", perimeter);
    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d", &n);
    int a = sqrt(n), b;
    if(n % a) {
        b = n / a + 1;
    } else {
        b = n / a;
    }
    printf("%d\n", 2 * (a + b));
    return 0;
}

#include<stdio.h>
#include <math.h>

int main()
{
    double n;
    int a, b;
    scanf("%lf20222", &n);
    a = ceil(sqrt(n));
    b = ceil(n/a);
    printf("%d\n", 2*(a+b));

    return 0;
}

#include<stdio.h>
#include <math.h>
int main(){
    int sqr,input,k2;
    scanf("%d",&input);
    sqr=sqrt(input);
    k2=sqr;
    while(sqr*k2<input)k2++;
    printf("%d",(k2+sqr)*2);
    return 0;
}

#include "stdio.h"
#include "math.h"

int main ()
{
	int n,i,j,num;
	scanf("%d",&n);
	for (i=1;;i++)
	{
		if (n<pow(i,2))
		break;
	}
	i=i-1;
	num=4*i;
	j=n-pow(i,2);
	for (int a=1;a<=j;a++)
	{
		if(a==1 || a==i+1)
		{
			num+=2;
		}
	}
	printf("%d",num);
}

#include<stdio.h>
#include<math.h>
int main(){
    int N, i, per, r, dis, div1, div, div2;
    scanf("%d",&N);
    r=sqrt(N);
    per=r*4;
    dis=N-(r*r);
    if(dis){
        if(dis<=r){
            per=per+2;
        }
        if(dis>r){
           div=dis/r;
           div1=dis%r;
           if(div1){
               div++;
           }
           per=per+div*2;
        }
    }
    printf("%d",per);
}

#include<stdio.h>
#include<math.h>
int main(void)
{
unsigned long long int N;  // upto order  10^6
scanf(" %llu", &N );
unsigned long long int squareorder = sqrt(N);
unsigned long long int order = N - (squareorder * squareorder);
unsigned long long int perimeter ;
if(order == 0)
    perimeter = 4 * squareorder;
else if(order > squareorder)
    perimeter = 4 * squareorder + 4 * order -  2 * order - 2 * (order - 1) + 2;
else
    perimeter = 4 * squareorder + 4 * order -  2 * order - 2 * (order - 1);
printf("%llu\n",perimeter);
return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
    int n,i,y=2,result=0,min=4;
    int inc=4;
    double z;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        if(i==y){
            min=(min-1)+3;
            y+=inc;
            inc+=2;
        }
        z = sqrt(i);
        if(z==(int)z){
            min=(min-1)+3;
        }
    }
    printf("%d",min);
}

#include<stdio.h>
int main()
{
    int n,i,x,y,z,p;
    scanf("%d",&n);

    if(n==1)
        printf("4\n");
    else
    {
    for(i=2;i<=n;i++)
    {
        if(i*i>n)
        {
           x=i-1;
           break;
        }
    }
    y=n/x;
    z=n%x;
    if(z==0)
    printf("%d\n",x*2+y*2);
    else
    {
        p=x*2+y*2-z;
        if(z==1)
            p=p+3;
        else
            p=p+4+(z-2);
        printf("%d\n",p);
    }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main(void)
{
    long long N,x,y,sum;
    scanf("%lld",&N);
    x = sqrt(N);
    y = N-x*x;
    if(y==0){
        sum = 4*x;
    }
    else if(y>0 && y<=x){
        sum = 4*x+2;
    }
    else{
        sum = 4*x+4;
    }
    printf("%lld",sum);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,a;
    scanf("%d",&n);
    a=sqrt(n);
    if(a*a==n)
    {
        printf("%d\n",(4*a));
    }
    else if(n<=((a*a)+a))
    {
        printf("%d\n",(4*a+2));
    }
    else
    {
        printf("%d\n",(4*a+4));
    }
    return 0;
}

#include <stdio.h>

int main()
{
    int n,weight,height,p,minP;
    scanf("%d",&n);
    weight = 1;
    while(weight <= n)
    {
        if(n % weight ==0)
            height = n/weight;
        else
            height = n/weight + 1;
        p = 2*(height+weight);
        if(weight == 1)
            minP = p;
        else
            if(p < minP)
                minP = p;
        weight++;
    }
    printf("%d",minP);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int N,p;
    scanf("%lld",&N);
    p=sqrt(N);
    if(p*p>=N)
    {
        printf("%d",(4*p));
    }
    else if(p*(p+1)>=N)
    {
        printf("%d",((2*p)+(2*(p+1))));
    }
    else
    {
        printf("%d",4*(p+1));
    }
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,r;
    scanf("%d",&n);
    r = sqrt(n);
    if(r*r == n)
        printf("%d\n",4*r);
    else if(n <= r*r + r)
        printf("%d\n",4*r+2);
    else
        printf("%d\n",4*r+4);
    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    int  num,root;
    double root2;
    scanf("%d",&num);
    root=sqrt(num);
    if(root*root==num)
        printf("%d\n",root*4);
    else
    {
        double res=(num*1.0)/root;
        root2=ceil(res);
        int ans=(root2+root)*2.0;
        printf("%d\n",ans);
    }

    return 0;
}

#include <stdio.h>
#include <math.h>
int main ()

{
    int n,i,full,square,rest;
    double root;
    scanf ("%d",&n);
    if (n==1||n==2||n==3)
    {
        if (n==1)
        {
            printf ("4");
            return 0;
        }
        else if (n==2)
        {
            printf ("6");
            return 0;
        }
        else
        {
            printf ("8");
            return 0;
        }
    }
    else {

    root = sqrt(n);
    full = floor(root);
    if (root==full)
    {
        printf ("%d",4*full);
        return 0;
    }
    else
    {
        square = pow(full,2);
        rest = n - square;
        if (rest<=full)
        {
            printf ("%d",(4*full)+2);
            return 0;
        }
        else if (rest>full)
        {
            if (rest%full==0)
            {printf ("%d",(4*full)+((rest/full)*2));
            return 0;}
            else
            {
            printf ("%d",(4*full)+2+((rest/full)*2));
            return 0;
            }

        }
    }
    }
}

#include<stdio.h>
#include<math.h>

int main(){
int n;
scanf("%d",&n);
int sq=n;
while(sqrt(sq)!=(int)sqrt(sq)){
sq++;
}

int peri=4*sqrt(sq);
int d=sq-n;
int val=0;
int a=sqrt(sq);
if(d>=a){
val=val+2;
d=d-a;
a--;}
int cnt=0;

while(d!=0){
cnt++;
if(d>=a){
val=val+2;
d=d-a;
}
if(d<a){
break;
}
if(cnt==2){
a--;
cnt=0;
}

}
peri=peri-val;
printf("%d",peri);

return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	int x = pow(n,0.5);
	//printf("%d\n",x);
	int l = pow(x,2);
	int k = 4*x;
	int z = n-l;
	if(x < z)
		k = k+4;
	else if(z)
		k+=2;
	printf("%d\n",k);

	return 0;

}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int k=sqrt(n);
    int a=n/k;
    int p=0;
    int l=n%k;
    p=k+2*a;
    if(l==1)
        p+=3+(k-l);
    else if(l==0)
        p+=k-l;
    else if(l>1)
        p+=2+l+k-l;
    printf("%d",p);
    return 0;
}

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    int n,p=0;
    scanf("%d",&n);
    int j=sqrt(n);
    int k=j*j;
    if(n==k)
    p=4*sqrt(n);
    else
    {
    	p=2*j;
    	int rem=n-k;
    	if(rem<=j)
    	{
    		if(rem>1)
    		p=p+rem+2+j+(j-rem);
    		else
    		p=p+3+(j-rem)+j;
    	}

    	else
    	{
    		p=p+(j+2);
    		if((rem-j)>1)
    		p=p+(rem-j)+2+(j-(rem-j));
    		else
    		p=p+3+(j-(rem-j));
    	}
    }
    printf("%d",p);
    }

#include<stdio.h>
#include<math.h>
int main()
{
    int n,a,t;
    scanf("%d",&n);
    a = ((2*sqrt(n))+ 0.9999);
    t =(2*a);
    printf("%d",t);
}

#include<stdio.h>
#include<math.h>
int main(){
    int num;
    scanf("%d",&num);
    int a = (int)sqrt(num);
    if(num - a*a >a)
        a = 4*a + 4;
    else if(num - a*a>0)
        a = 4*a +2;
    else if(num - a*a==0)
        a = 4*a;
    printf("%d",a);
    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    int n,sr;
    scanf("%d",&n);
    sr=(int) sqrt(n);
    if((sr*sr)==n)
        printf("%d",sr*4);
    else if((sr*sr+sr)>=n)
        printf("%d",sr*4+2);

    else
        printf("%d",(sr+1)*4);

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int n;
    scanf("%d", &n);
    int square = 1;
    int closest = n;
    int value;
    while(square*square <= n){
        if (n-square*square < closest){
            closest = n-square*square;
            value = square;
        }
        square++;
    }
    int ans;
    if (closest != 0)
        ans = value*4 + 2;
    else if (closest == 0)
        ans = value*4;
    if ((value+1)*(value+1) - n < closest)
        ans = (value+1)*4;
    printf("%d", ans);

}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include<math.h>

int main()
{
	int n;
	scanf("%d",&n);
	if(n==2)
	printf("6");
	else if(n==3)
	printf("8");
	else if(sqrt(n)-(int)sqrt(n)==0)
	printf("%d",(int)sqrt(n)*4);
	else
	{
		int s=sqrt(n);
		int res=4*s;
		int y=n-s*s;
		if(y<=s)
		printf("%d",res+2);
		else
		printf("%d",res+4);
	}
	return 0;
}

#include<stdio.h>
#include<math.h>

main()
{
    long int n;
    scanf("%ld",&n);
    long int sr;
    sr=sqrt(n);
    long int diff=n-(sr*sr);
    double add=ceil((double)diff/sr);

    long int ans=(4*sr)+(2*add);
    printf("%ld\n",ans);
}

#include <stdio.h>
#include <math.h>
int main() {
	int a,b,N;
	scanf("%d", &N);
	a = sqrt(N);
	b = a;
	if (a * b >= N) {
		printf("%d", 2*a + 2*b);
	} else if ((a+1) * b >= N) {
		printf("%d", 2*(a+1) + 2*b);
	} else {
		printf("%d", 2*(a+1) + 2*(b+1));
	}
}

#include<stdio.h>

int main(){

    int m;
    scanf("%d",&m);
    for(int i=0;i<1200;i++){
        if(i*i >= m){
            printf("%d\n",4*i);
            break;
        }
        else if(i*i + i >= m){
            printf("%d\n",4*i + 2);
            break;
        }
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
int main()
{
	long long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;
	scanf("%lld", &n);
	/*
		scanf("%s", s1);
		len=strlen(s1);
		for(i=0;i<len;i++)
		str[i+1]=s1[i];
	 */
	long long bnd=sqrt(n);
	long long rem=n-bnd*bnd;
	if(rem==0)
		printf("%lld\n",4*bnd);
	else
	{
		if(rem%bnd==0)
		{
			printf("%lld\n",4*bnd+(rem/bnd)*2);
		}
		else{

		printf("%lld\n",4*bnd+(rem/bnd + 1)*2);
		}
	}

	return 0;
}

#include <stdio.h>

int main(void) {
	// your code goes here

	int i = 1,near,remaining,output;
	float count;
	scanf("%f",&count);
	while((count/i)>i)
	{
		i++;

	}
	//near = i;
	if(i*i != count)
	{
	 i = i-1;
	}
	remaining = count - i*i;
	if(remaining == 0)
	{
		output = i*4;
		printf("%d",output);
	}
	else if(remaining <=i && remaining !=0)
	{
		output = i*4 + 2;
		printf("%d",output);
	}
	else
	{
		output = i*4 + 4;
		printf("%d",output);
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,ans,a;
    scanf("%d",&n);
    a=sqrt(n);
    if(a*a==n)
        ans=a*4;
    else
    {
        if((a+1)*a<n)
            ans=(a+1)*4;
        else ans=2*(a*2+1);
    }
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
int mini(int a, int b)
{
if(a<=b)return a;
return b;
}
int dp[2000005];
int main()
{
int n;
scanf("%d",&n);
int i;
for(i=1;i<=2*n+1;i++)
dp[i] = 2*i + 2;
int j;
for(i=1;i<=2*n;i++)
for(j=i;j<=2*n;j+=i)
dp[j] = mini(dp[j],2*(i+j/i));
for(i=2*n;i>=1;i--)
dp[i] = mini(dp[i],dp[i+1]);
printf("%d\n",dp[n]);
return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int n,k,x,y1,y2,z1,z2,a;

    scanf("%d",&n);

    if(n==1){
        printf("4");
    }
    else if(n==2){
        printf("6");
    }

    else {
        k=sqrt(n);
        x=k+1;
        y1=k*k;
        y2=x*x;
        z1=n-y1;
        z2=y2-n;

        if(z1<z2){
            a=k;
            if(n<=a*a){
                printf("%d",a*4);
            }
            else if(n>a*a){
                printf("%d",(a*4)+2);
            }
        }
        else if(z1>z2){
            a=x;
            if(n<=a*a){
                printf("%d",a*4);
            }
            else if(n>a*a){
                printf("%d",(a*4)+2);
            }
        }
    }

    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int N,x,y;

    scanf("%d", &N);
    x= sqrt(N);

    if(x*x==N) printf("%d\n",4*x);
    else
    {
        x++;
        y= 2*(N/x)+2*x;

        if(N%x!=0) y+=2;

        printf("%d\n",y);

    }

    return 0;
}

#include <stdio.h>
int main() {
    int n,sum=0,temp;
    scanf("%d",&n);
    for(int i=1;i*i<=n;i++) {
        if(i*i<=n) {
            temp=i;
        }
    }
    if(n-temp*temp==0) {
        sum=4*temp;
    }
    else if(n-temp*temp>temp) {
        sum=4*temp+4;
    }
    else if(n-temp*temp<=temp){
        sum=4*temp+2;
    }
    printf("%d\n",sum);
    return 0;
}

#include <stdio.h>

int main(void)
{
	int n, r, l, f = 0;
	scanf("%d", &n);
	for (l = 1 ;; l = l + 1)
	{
		for (r = l - 1; r <= l; r = r + 1)
		{
			if (r * l >= n)
			{
				printf("%d", 2 * (r + l));
				f = 1;
				break;
			}
		}
		if (f)
			break;
	}
	return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
	int i,j,k,l,m,n,q;
	scanf("%d",&n);
	q=sqrt(n);
	m=(n-(q*q))/q;
	if((n-(q*q))%q!=0)
	m++;
	m*=2;
	m+=q*4;
	printf("%d\n",m);

	return 0;
}

#include<stdio.h>
#include<math.h>

int main(void){
int a,c;
scanf("%d ",&a);
int d;
d= sqrt(a);

int e=a-d*d;
if(e==0){
    printf("%d",d*4);
}
else if((e/d)>0){
    int b=e/d;
     c= (b+d)*2 +d*2;
    int f= e%d;
    if(f==1){
        c=c+f*2;
    }
    else if(f==0){
     printf("%d",c);
    }
    else{
        c=c+2;
        printf("%d",c);
    }

}
else{
    int w;
    if(e==1){
      w=  d*4 +e*2;
    }
    else{
        w=d*4+2;
    }
    printf("%d",w);
}

}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
int main()
{
	long long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;
	scanf("%lld", &n);
	/*
		scanf("%s", s1);
		len=strlen(s1);
		for(i=0;i<len;i++)
		str[i+1]=s1[i];
	 */
	long long bnd=sqrt(n);
	long long rem=n-bnd*bnd;
	if(rem==0)
		printf("%lld\n",4*bnd);
	else

	printf("%lld\n",4*bnd+(rem/4 + 1)*2);

	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a,p;
    scanf("%d",&a);
    int i,j;
    for(i=1; ;i++)
        for(j=1;j<=i;j++)
        {
            if(i*j>=a)
            {
             p=4*sqrt(i*j);
             printf("%d",p);
             return;
            }
        }
    return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;
scanf("%d",&n);
	j = (int)(4*(sqrt(n))+0.999);
printf("%d",j);
}

#include <stdio.h>
#include <math.h>
int main ()

{
    int n,i,full,square,rest;
    double root;
    scanf ("%d",&n);
    if (n==1||n==2||n==3)
    {
        if (n==1)
        {
            printf ("4");
            return 0;
        }
        else if (n==2)
        {
            printf ("6");
            return 0;
        }
        else
        {
            printf ("8");
            return 0;
        }
    }
    else {

    root = sqrt(n);
    full = floor(root);
    if (root==full)
    {
        printf ("%d",4*full);
        return 0;
    }
    else
    {
        square = pow(full,2);
        rest = n - square;
        if (rest<=full)
        {
            printf ("%d",(4*full)+2);
            return 0;
        }
        else if (rest>full)
        {
            if ((rest)%(full-1)==0)
            {
                printf ("%d",(4*full)+(2*(rest/(full)))+(2*(rest%(full))));
                return 0;
            }
            else
            {
                printf ("%d",(4*full)+(2*(rest/(full))+2));
                return 0;

            }
        }
    }
    }
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int PW(int a);

int main()
{

 int n;
 scanf("%d",&n);

 int k=1;
 int t=1;
 while(k<=n)
 {
   if(k==n)
   {
     printf("%d\n",4*t);
     exit(0);
   }
   t++;
   k=PW(t);
 }

 int rem = n - PW(t-1);

 int res = 4*(t-1) + (2*((rem/(t-1))+1));
 printf("%d\n",res);
 return 0;
}

int PW(int a)
{
  return a*a;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	scanf("%d",&n);
	int x = pow(n,0.5);
	//printf("%d\n",x);
	int l = pow(x,2);
	int k = 4*x;
	int z = n-l;
	if(z == 0)
		printf("%d\n",k);
	else if(z < x)
		printf("%d\n",k+2);
	else
		printf("%d\n",k+4);
	return 0;

}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,a,t;
    scanf("%d",&n);
    a = ((2*sqrt(n))+ 0.9);
    t =(2*a);
    printf("%d",t);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N,i,j,a=0,b=0;
    scanf("%d",&N);
    for(i=0;i<=265;i++){
        a=i*i;
        if(a>=N){
            a=i;    //printf("a=%d\n",a);
            break;
        }
    }
    for(j=i;j>=1;j--){
        b=j*a;
       // printf("B0=%d   %d\n",b,j);
        if(b==N){
            b=j;       //printf("b1=%d\n",b);
            break;
        }
        else if (b<N){
            b=++j;    // printf("b2=%d   %d\n",b,j);
            break;
        }
    }
    printf("%d\n",2*(a+b));
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,a,t;
    scanf("%d",&n);
    a = ((2*sqrt(n))+ 0.99);
    t =(2*a);
    printf("%d",t);
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;
scanf("%d",&n);
if ((sqrt(n)-(int)(sqrt(n))<0.0005))
	j = (int)(4*(sqrt(n)));
else
	j = (int)(4*(sqrt(n))+1);
printf("%d",j);
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int n;
    scanf("%d", &n);
    int square = 1;
    int closest = n;
    int value;
    while(square*square <= n){
        if (n-square*square < closest){
            closest = n-square*square;
            value = square;
        }
        square++;
    }
    int ans;
    if (closest != 0)
        ans = value*4 + 2 + closest;
    else if (closest == 0)
        ans = value*4;
    if ((value+1)*(value+1) - n < closest)
        ans = (value+1)*4;
    printf("%d", ans);

}

#include<stdio.h>
#include<math.h>
int main(void)
{
unsigned long long int N;  // upto order  10^6
scanf(" %llu", &N );
unsigned long long int squareorder = sqrt(N);
unsigned long long int order = N % (squareorder * squareorder);
unsigned long long int perimeter ;
if(order == 0)
    perimeter = 4 * squareorder;
else if(order > squareorder)
    perimeter = 4 * squareorder + 4 * order -  2 * order - 2 * (order - 1) + 2;
else
    perimeter = 4 * squareorder + 4 * order -  2 * order - 2 * (order - 1);
printf("%llu\n",perimeter);
return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
	long long int n,z;
	scanf("%lld",&n);
	double k;
	k=sqrt(n);
	{
	z=floor(k);
	if ((z)*(z)==n)
		{printf("%lld",2*n);return 0;}
	else if (z*(z+1)>n && z*z<n)
		printf("%lld",2*(z+z+1));
	else
		printf("%lld",2*(z+z+2));
    }
}

#include<stdio.h>
int main()
{
    long long int n,i,k,d,a;
    scanf("%lld",&n);
    for(i=1;i<n;i++)
    {
        if(i*i>=n)
        {
          k=i;
          break;
        }
    }
    for(i=k;i>0;i--)
    {
        if(k*i<n)
        {
            d=i+1;
            break;
        }
    }
    a=2*k+2*d;
    printf("%lld",a);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,blck,root,ext;
    scanf("%d",&n);
    root=(int)sqrt(n);
    blck=4*root;
    ext=n-root*root;
    if(!ext)
    {
        printf("%d",blck);
        return 0;
    }
    else if(ext>root)
    {
        ext=ext/root;
        blck+=2*(ext+1);
    }
    else
    {
        blck+=2;
    }
    printf("%d",blck);
    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d",&n);
    int x = sqrt(n);

    if(x*x==n) printf("%d\n",n*2);

    else{
        int dif = n - (x*x);

        if(dif>x) printf("%d\n",x*4+4);
            else printf("%d\n", x*4+2);
    }

    return 0;
}

#include<stdio.h>

int main()
{
 long N;
 long squares[1005];
 long maxsquare;
 long maxlines;
 long remainder;
 long squareside;
 long perimeter;
 int i;
 for(i=0;i<1000;i++) squares[i]=i*i;

 scanf("%ld",&N);
 for(i=1;i<1000;i++)
 {
  maxsquare=squares[i];
  squareside=i;
  if(squares[i+1]>N) break;
 }

 remainder=N-maxsquare;
 maxlines=remainder/squareside;
 remainder=remainder-maxlines*squareside;

 perimeter=4*squareside;
 if(maxlines!=0) perimeter+= 2*maxlines;
 if(remainder!=0) perimeter+=2;
 printf("%ld\n",perimeter);
 return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;
scanf("%d",&n);
if ((sqrt(n)-(int)(sqrt(n))<0.00005))
	j = (int)(4*(sqrt(n)));
else
	j = (int)(4*(sqrt(n))+1);
printf("%d",j);
}

#include<stdio.h>
#include<math.h>

int main(void){
int a,c;
scanf("%d ",&a);
int d;
d= sqrt(a);

int e=a-d*d;
if(e==0){
    printf("%d",d*4);
}
else if((e/d)>0){
    int b=e/d;
     c= (b+d)*2 +d*2;
    int f= e%d;
    if(f==1){
        c=c+f*2;
    }
    else{
    c=c+2;
    }
    printf("%d",c);

}
else{
    int w;
    if(e==1){
      w=  d*4 +e*2;
    }
    else{
        w=d*4+2;
    }
    printf("%d",w);
}

}

#include<stdio.h>
#include<math.h>
int main(){
    int num;
    scanf("%d",&num);
    int a = (int)sqrt(num);
    if(num - a*a >a)
        a = 4*a + 6;
    else if(num - a*a >0)
        a = 4*a +3;
    else if(num-a*a==0)
        a = 4*a;
    printf("%d",a);
    return 0;
}

#include <stdio.h>
#include <math.h>
int main ()

{
    int n,i,full,square,rest;
    double root;
    scanf ("%d",&n);
    if (n==1||n==2||n==3)
    {
        if (n==1)
        {
            printf ("4");
            return 0;
        }
        else if (n==2)
        {
            printf ("6");
            return 0;
        }
        else
        {
            printf ("8");
            return 0;
        }
    }
    else {

    root = sqrt(n);
    full = floor(root);
    if (root==full)
    {
        printf ("%d",4*full);
        return 0;
    }
    else
    {
        square = pow(full,2);
        rest = n - square;
        if (rest<=full)
        {
            printf ("%d",(4*full)+2);
            return 0;
        }
        else if (rest>full)
        {
            printf ("%d",(4*full)+2+((rest/full)*2));
            return 0;
        }
    }
    }
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include<math.h>

int main()
{
	int n;
	scanf("%d",&n);
	if(sqrt(n)-(int)sqrt(n)==0)
	printf("%d",(int)sqrt(n)*4);
	else
	{
		int s=(int)sqrt(n);
		int res=4*s;
		int y=n-s*s;
		int b=y/s+1;
		printf("%d",res+2*b);
	}
	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a,c,d,e,f,g;
    double b;

    d = 4;
    e = c*c;
    f = 2;
    scanf("%d", &a);
    b = sqrt(a);
    c = sqrt(a);
    g = c*d;
    if(b-c == 0)
    {
        printf("%d", g);
    }
    else if(a-e >= c && a-e <= c*f)
    {
        printf("%d", g+f);
    }
    else
    {
        printf("%d", g+d);
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
int main()
{
	long long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;
	scanf("%lld", &n);
	/*
		scanf("%s", s1);
		len=strlen(s1);
		for(i=0;i<len;i++)
		str[i+1]=s1[i];
	 */
	long long bnd=sqrt(n);
	long long rem=n-bnd*bnd;
	if(rem==0)
		printf("%lld\n",4*bnd);
	else
	{
		if(rem%bnd==0)
			printf("%lld\n",4*bnd+(rem/4)*2);
		else
		printf("%lld\n",4*bnd+(rem/4 + 1)*2);
	}

	return 0;
}

#include <stdio.h>
#include <math.h>
int main ()

{
    int n,i,full,square,rest;
    double root;
    scanf ("%d",&n);
    if (n==1||n==2||n==3)
    {
        if (n==1)
        {
            printf ("4");
            return 0;
        }
        else if (n==2)
        {
            printf ("6");
            return 0;
        }
        else
        {
            printf ("8");
            return 0;
        }
    }
    else {

    root = sqrt(n);
    full = floor(root);
    if (root==full)
    {
        printf ("%d",4*full);
        return 0;
    }
    else
    {
        square = pow(full,2);
        rest = n - square;
        if (rest<full)
        {
            printf ("%d",(4*full)+2);
            return 0;
        }
        else if (rest>full)
        {
            if ((rest)%(full-1)==0)
            {
                printf ("%d",(4*full)+(2*(rest/(full-1))));
                return 0;
            }
            else
            {
                printf ("%d",(4*full)+(2*((rest/(full-1))+1)));
                return 0;

            }
        }
    }
    }
}

#include <stdio.h>
#include <math.h>

int main()
{
    int a;
    scanf("%d",&a);
    float x=4*sqrt(a);
    int y=x;
    if(x>y)
    {
        int z=a/10;
        y+=z;
    }
    printf("%d",y);

    return 0;
}

#include<stdio.h>
#include<math.h>

int main(void){
int a,c;
scanf("%d ",&a);
int d;
d= sqrt(a);

int e=a-d*d;
if(e==0){
    printf("%d",d*4);
}
else if((e/d)>0){
    int b=e/d;
     c= (b+d)*2 +d*2;
    int f= e%d;
    if(f==1){
        c=c+f*2;
    }
    else{
    c=c+f;
    }
    printf("%d",c);

}
else{
    int w;
    if(e==1){
        d*4 +e*2;
    }
    else{
        w=d*4+e;
    }
    printf("%d",w);
}

}

#include<stdio.h>
int main()
{
    long long int n,m,r,s,t;
    scanf("%lld",&n);
    for(m=1;(m)*(m)<=n;m++)
    {
        if(m*m==n)
        {
            r=4*m;
            break;
        }
        else
        {
        s=4*(m+1);
        t=4*m+2;
        }
    }
if((m-1)*(m-1)==n)
printf("%lld",r);
else
{
    if((m-1)*(m)>=n)
    printf("%lld",t);
    else
        printf("%lld",s);
}
    return 0;
}

#include<stdio.h>
#include<math.h>

int main(void){
int a,c;
scanf("%d ",&a);
int d;
d= sqrt(a);

int e=a-d*d;
if(e==0){
    printf("%d",d*4);
}
else if((e/d)>0){
    int b=e/d;
     c= (b+d)*2 +d*2;
    int f= e%d;
    if(f==1){
        c=c+f*2;
    }
    else{
    c=c+f;
    }
    printf("%d",c);

}
else{
    int w;
    if(e==1){
      w=  d*4 +e*2;
    }
    else{
        w=d*4+e;
    }
    printf("%d",w);
}

}

#include<stdio.h>
#include<math.h>
int main()
{int n,d;
float b,a;
scanf("%f",&a);
b=sqrt(a);
d=b;
if(b==d)
 {
     printf("%d",d*4);}

else {
n=((d+1)*(d+1)-d*d)/2;
        if(b*b+n>=a)
    printf("%d",d*4+2);
else
   printf("%d",(d+1)*4);
   }
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;

scanf("%d",&n);
j = (int)(4*(sqrt(n))+0.999);
printf("%d",j);
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,blck,root;
    scanf("%d",&n);
    root=(int)sqrt(n);
    blck=4*root;
    blck+=((int)((n-root*root)/root))*2;
    blck+=(n-root*root)%root;
    printf("%d",blck);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
    int num;
    scanf("%d",&num);
    int a = (int)sqrt(num);
    if(num - a*a >a)
        a = 4*a + 4;
    else
        a = 4*a +2;
    printf("%d",a);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int n,a,b;
    float f;

    scanf("%d",&n);
    a = sqrt(n);
    f = sqrt(n);

    if(a==f)
    {
        b = a*4;
    }
    if(a!=f)
    {
        if((n-a*a)<a)
            b = a*4+2;
        else
            b = (a+1)*4;

    }

    printf("%d",b);
}

#include<stdio.h>
#include <math.h>
int main(){
    int sqr,input,k2;
    scanf("%d",&input);
    sqr=sqrt(input);
    printf("%d",sqr);
    k2=sqr;
    while(sqr*k2<input)k2++;
    printf("%d",(k2+sqr)*2);
    return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;
scanf("%d",&n);
if ((sqrt(n)-(int)(sqrt(n))<0.00005))
	j = (int)(4*(sqrt(n)));
else
	j = (int)(4*(sqrt(n))+1);
printf("%d",j);
}

#include <stdio.h>
#include <math.h>

int main()
{
    int n,flag = 0;
    scanf("%d",&n);

    int peri,x,y;
    int temp = sqrt(n);
    int temp1 = temp +1;

    int sqrx = temp*temp;
    int sqry = temp1*temp1;

    if((sqrx) == n)
        flag =1;

    if(flag == 1)
        peri = 4 * temp;

    if(flag == 0)
    {
        x = (sqrx) - n;
        y = (sqry) - n;

        if(x < 0)
            x *= -1;

        if(y< 0)
            y*= -1;

        //printf("#%d $%d\n",x,y);

        if(x < y)
            peri = (4*temp) + x;

        if(x > y)
            peri = (4*temp1);
    }

    printf("%d",peri);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

/*Lazy Security Guard*/
int main()
{
    int input_num, perimeter,temp,count = 0;
    scanf("%d",&input_num);
    temp = input_num;
    if(input_num == 1)
    {
        perimeter = 4;
    }
    else if(input_num <= 0)
    {
        perimeter = 0;
    }
    else
    {
        while(temp != 1)
        {
            temp /= 2;
            count++;
        }
        perimeter = count * 4;
        temp = input_num - (count*count);
        while(temp > 0)
        {
            temp = temp - count;
            perimeter = perimeter + 2;
        }

    }
    printf("%d", perimeter);
    return 0;
}

#include "stdio.h"
#include "math.h"

int main ()
{
	int n,i,j,num;
	scanf("%d",&n);
	for (i=1;;i++)
	{
		if (n<pow(i,2))
		break;
	}
	i=i-1;
	num=4*i;
	j=n-pow(i,2);
	for (int a=1;a<=j;a++)
	{
		if(a==1 || a==i)
		{
			num+=2;
		}
	}
	printf("%d",num);
}

#include <stdio.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d",&n);
    int x = sqrt(n);

    if(x*x==n) printf("%d\n",n*2);

    else{
        int dif = n - (x*x);

        if(dif>x) printf("%d\n",x*4+4);
            else printf("%d\n", x*4+2);
    }

    return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;
scanf("%d",&n);
	j = (int)(4*(sqrt(n))+0.999);
printf("%d",j);
}

#include<stdio.h>
int main()
{
    long long int n,i,k,d,a;
    scanf("%lld",&n);
    if(n==1)
    printf("4");
    else
    {
    for(i=1;i<n;i++)
    {
        if(i*i>=n)
        {
          k=i;
          break;
        }
    }
    for(i=k;i>0;i--)
    {
        if(k*i<n)
        {
            d=i+1;
            break;
        }
    }
    a=2*k+2*d;
    printf("%lld",a);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N,i,j,a=0,b=0;
    scanf("%d",&N);
    for(i=0;i<=265;i++){
        a=i*i;
        if(a>=N){
            a=i;    //printf("a=%d\n",a);
            break;
        }
    }
    for(j=i;j>1;j--){
        b=j*a;
        //printf("B0=%d   %d\n",b,j);
        if(b==N){
            b=j;       //printf("b1=%d\n",b);
            break;
        }
        else if (b<N){
            b=++j;     //printf("b2=%d   %d\n",b,j);
            break;
        }
    }
    printf("%d\n",2*(a+b));
    return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
    int num;
    scanf("%d",&num);
    int a = (int)sqrt(num);
    if(num - a*a >a)
        a = 4*a + 4;
    else
        a = 4*a +2;
    printf("%d",a);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,i,x,y,z,p;
    scanf("%d",&n);

    for(i=2;i<=n;i++)
    {
        if(i*i>n)
        {
           x=i-1;
           break;
        }
    }
    y=n/x;
    z=n%x;
    if(z==0)
    printf("%d\n",x*2+y*2);
    else
    {
        p=x*2+y*2-z;
        if(z==1)
            p=p+3;
        else
            p=p+4+(z-2);
        printf("%d\n",p);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,r,d=2,s;
    scanf("%d",&n);
    for(m=1;m*m<=n;m++)
    {
        if(m*m==n)
        {
            r=4*m;
        }
        else
        {
        d++;
        s=4*d;
        }
    }
if(m*m==n)
printf("%d",r);
else
    printf("%d",s);
return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include<math.h>

int main()
{
	int n;
	scanf("%d",&n);
	if(n==2)
	printf("6");
	else if(n==3)
	printf("8");
	else if(sqrt(n)-(int)sqrt(n)==0)
	printf("%d",(int)sqrt(n)*4);
	else
	{
		int s=(int)sqrt(n);
		int res=4*s;
		int y=n-s*s;
		int b=y/s+1;
		int c=y-b*s;
		printf("%d",res+2*b+(c>0?c:0));
	}
	return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;

scanf("%d",&n);
j = (int)(4*(sqrt(n))+0.999);
printf("%d",j);
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include<math.h>

int main()
{
	int n;
	scanf("%d",&n);
	if(sqrt(n)-(int)sqrt(n)==0)
	printf("%d",(int)sqrt(n)*4);
	else
	{
		int s=(int)sqrt(n);
		int res=4*s;
		int y=n-s*s;
		int b=y/s+1;
		int c=y-b*s;
		printf("%d",res+2*b+(c>0?c:0));
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{int n,d;
float b,a;
scanf("%f",&a);
b=sqrt(a);
d=b;
if(b==d)
 {
     printf("%d",d*4);}

else {
n=((d+1)*(d+1)-d*d)/2;
        if(b*b+n>=a)
    printf("%d",d*4+2);
else
   printf("%d",(d+1)*4);
   }
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int blocks,i=0;
    scanf("%d", &blocks);
    while(i*i<=blocks)
    {
        ++i;
    }
    --i;
    int szeleszama=4*i;//i*i s negyzet oldala
    if(blocks-i*i>=i)
    {
        szeleszama+=4;
    }
    else if(blocks==i*i)
    {
        //nothing really xd
    }
    else
    {
        szeleszama+=2;
    }
    printf("%d",szeleszama);
    return 0;
}

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int j;
int n;
scanf("%d",&n);
if ((sqrt(n)-(int)(sqrt(n))<0.00005))
	j = (int)(4*(sqrt(n)));
else
	j = (int)(4*(sqrt(n))+1);
printf("%d",j);
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,a,t;
    scanf("%d",&n);
    a = ((2*sqrt(n))+ 0.5);
    t =(2*a);
    printf("%d",t);
}

#include<stdio.h>
int main()
{
    int n,m,r,d=2,s;
    scanf("%d",&n);
    for(m=1;m*m<=n;m++)
    {
        if(m*m==n)
        {
            r=4*(m);
        }
        else
        {
        d++;
        s=4*d;
        }
    }
printf("%d",r||s);
return 0;
}

#include<stdio.h>
int main()
{
    int n,m,r,d=2,s;
    scanf("%d",&n);
    for(m=1;(m+1)*(m+1)<=n;m++)
    {
        if(m*m==n)
        {
            r=4*m;
        }
        else
        {
        d++;
        s=4*d;
        }
    }
if(m*m==n)
printf("%d",r);
else
    printf("%d",s);
return 0;
}


#include <stdio.h>

long long power_mod (long long a, long long b, long long mod_num) {
  long long ans = 1LL;

  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans * a) % mod_num;
    }
  }

  return ans;
}

int main () {
  int n = 0;
  int k = 0;

  int res = 0;

  long long ans = 0LL;
  long long mod_num = 1000000007LL;

  long long fact[100001] = {};
  long long invf[100001] = {};

  res = scanf("%d", &n);
  res = scanf("%d", &k);

  if (n <= k) {
    printf("%lld\n", power_mod(2LL, (long long)n, mod_num));
    return 0;
  }

  fact[0] = 1LL;
  for (int i = 0; i < n; i++) {
    fact[i+1] = fact[i];
    fact[i+1] *= (long long) (i+1);
    fact[i+1] %= mod_num;
  }

  invf[n] = power_mod(fact[n], mod_num-2LL, mod_num);
  for (int i = n; i > 0; i--) {
    invf[i-1] = invf[i];
    invf[i-1] *= (long long)i;
    invf[i-1] %= mod_num;
  }

  for (int i = 0; i <= k; i++) {
    long long tmp = invf[i];
    tmp = (tmp*invf[n-i])%mod_num;
    ans = (ans+tmp)%mod_num;
  }

  ans = (ans*fact[n])%mod_num;
  printf("%lld\n", ans);

  return 0;
}

#include <stdio.h>

#define N	100000
#define MD	1000000007

int vv[N + 1], ff[N + 1], gg[N + 1];

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, k_, k, ans;

	init();
	scanf("%d%d", &n, &k_);
	ans = 0;
	for (k = 0; k <= k_ && k <= n; k++)
		ans = (ans + choose(n, k)) % MD;
	printf("%d\n", ans);
	return 0;
}