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

int main()
{
    long long n,m,i,j=0,k=0,t,a=0,b,c,ck=0,dk=1;
    char str[1000];
    scanf("%d %d",&n,&k);

    for(i =0;i < n; i++)
    {
        scanf("%s",&str[i]);
    }

        a = arr[0] - 'a';
        ck+=a+1;
        for(i=1; i<n; i++){
            b = arr[i] - 'a';
            if(abs(a-b)>1 && m>1){
                ck+=(b+1);
                j++;
                dk++;
                a = arr[i] - 'a';
                if(j==m-1)
                    break;
            }
            else{
                continue;
            }
        }

    if(dk<m)
        printf("-1\n");
    else
        printf("%lld",ck);

}


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


#include<stdio.h>
int main(void)
{
long int n,m,div1,step;
scanf("%d",&n);
scanf("%d",&m);
if(n%2!=0)

{div1=((n-1)/2);
if((div1/m)!=0)
{
step=(((div1/m)+1)*m);
}
else
step=-1;
}
else
{div1=(n/2);
if((div1/m)!=0)
{
if(div1%m==0)
step=div1;
else
if(div/m==0)
step=(((div1/m)+1)*m);
}
else if(div/m==0)
step=-1;
}

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


#include <stdio.h>

int main(){
    int n, m, move, i, flag = 1;

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

    if(n%2 == 0){
        move = n/2;
    }else{
        move = (n/2)+1;
    }

    if(n == 2){
        printf("2");
    }else if(n < m){
        printf("-1");
    }else{
        for(i = 1; i<=t; i++){
            if(move%m == 0){
                printf("%d", move);
                break;
            }else{
                move = (move-1) + 2;
            }

            if(i == t){
                flag = 0;
            }
    }

    }

    if(flag == 0){
        printf("-1");
    }
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,m,a;
cin>>n>>m;
if(n<m)
cout<<"-1";

else if(n==m)
cout<<n;

else{
if(n%2==0)
a = n/2;
else a = 1 + (n-1)/2;

if(a%m==0)
cout<<a;
else{
int h=a/m;
a= (h+1)*m;
cout<<a;
}

}
return 0;
}


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


#include<stdio.h>
int main()
{
    int a,b,s=0;
    scanf("%d%d",&a,&b);
    while(a<=b)
    {
        sum+=1;
        a*=3;
        b*=2;
    }
    printf("%d",sum);
    return 0;
}


#include<stdio.h>
int main(void)
{
    int a,b,i;
    scanf("%d %d",&a,&b);
    for(i=1;a<b;i++)
    {
        a*=3；
        b*=2；
    }
    printf("%d",i);
    return 0;
}


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

int main()
{int a,b;
int count=0;

//printf("enter a and b");
//scanf("a=%d b=%d",&a,&b);
while(a<b){
 a=a*3;
b=b*2;
count++;
}
scanf("count=%d",&count)
printf("%d",count);
    return 0;
}


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

int main(void){
    int min[4]={0},max[4]={0},ans[4]={0};
    int num;
    int remain;
    scanf("%d",&num);
    scanf("%d %d",&min[1],&max[1]);
    scanf("%d %d",&min[2],&max[2]);
    scanf("%d %d",&min[3],&max[3]);
    for(int i=1;i<4;i++){
        num=num-min[i];
        ans[i]=min[i];
    }
    while(num>0){
        if(max[1]-min[1]>0){
            num--;
            max[1]--;
            ans++;
        }
        else if(max[2]-min[2]>0){
            num--;
            max[2]--;
            ans++;
        }
        else if(max[3]-min[3]>0){
            num--;
            max[3]--;
            ans++;
        }
    }
    printf("%d %d %d\n",ans[1],ans[2],ans[3]);
    return 0;
}


#include <stdio.h>

int main()
{
    int i,n,a,b,c,j,max[3],min[3],min_total=0,max_total=0,x=0,y=0,z;
    scanf("%d",&n);
    for(i=0;i<3;i++)
    {
         scanf("%d %d",&min[i],&max[i]);
         if(max[i]>x)
         {
             x=max[i];
             y=i;
         }

         min_total+=min[i];
         max_total+=max[i];
    }

        if(min_total==n)
        {
            printf("%d %d %d",min[0],min[1],min[2]);
            break;

        }
            else if(max_total==n)
        {
            printf("%d %d %d",max[0],max[1],max[2]);
            break;
        }
        else
        {
            printf("%d %d %d",(max[0]+min[0])/2,(max[1]+min[1])/2,(max[2]+min[2])/2);

        }

        return 0;

}


/* https://codeforces.com/contest/557/submission/35304038 (rainboy) */
#include <stdio.h>

int main() {
	int n, min1, max1, min2, max2, min3, max3, a, b, c;

	scanf("%d%d%d%d%d%d%d", &n, &min1, &max1, &min2, &max2, &min3, &max3);
	a = max1 < n - min2 - min3 ? max1 : n - min2 - min3;
	b = max2 < n - a - min3 ? max2 : n - a - min3;
	c = max3 < n - a - b ? max3 : n - a - b;
	printf("%d %d %d\n", a, b, c);
	return 0;
}


#include<stdio.h>
int main()
{
    int a, b, c;

    scanf("%d%d", %a, %b);

    c=a+b;

    printf("%d", c);

    return 0;
}


#include<cstdio>
using namespace std;
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}


#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
				printf("%d",a + b);
	return 0;
}


include<stdio.h>
#include<math.h>
int main()
{
        int a,b;
        scanf("%d %d",&a,&b);
        printf("%d",a+b);
return 0;
}


include<stdio.h>
int main(){
//Cf chudi
long long int a,b;
scanf("%lli%lli",a,b);
printf("%lli",a+b);
return 0;
}


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

int main(void){
    int a[3];
    int min, max;

    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    printf("%d", (a[0]+a[1]+a[2])/3)
    return 0;
}


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

void main(){//codeforces

    int n,a[3],j = 0;
    scanf("%d %d %d",&a[0],&a[1],&a[2]);

    qsort(a, 3, sizeof(a[0]), menorParaMaior);

    j = a[1]-a[0]+ a[2]-a[1];

    printf("%d\n",j);
  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,i;
    long long int a[3];
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<(a[1]-a[0])+(a[2]-a[1]);
    return 0;
}


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

int cmp(const void *a, const void *b);
void swap(char *a, char *b);

int main(void)
{
	char n[100];
	char m[100];
	scanf("%s%s", &n, &m);

	int n_length = strlen(n);
	int m_length = strlen(m);
	qsort(n, n_length, sizeof(char), cmp);

	int i = 0;
	while (n[i] == '0' && i < n_length) {
		i++;
	}
	swap(n + 0, n + i);

	int result = 1;
	if (n_length != m_length) {
		result = 0;
	} else {
		for (i = 0; i < n_length; i++) {
			if (n[i] != m[i]) {
				result = 0;
				break;
			}
		}
	}
	printf("%s\n", n);
	if (result == 1) {
		printf("OK\n");
	} else {
		printf("WRONG_ANSWER\n");
	}
	getch();
	return 0;
}

int cmp(const void *a, const void *b)
{
	return *(char *)a - *(char *)b;
}

void swap(char *a, char *b)
{
	char temp = *a;
	*a = *b;
	*b = temp;
}


#include<stdio.h>
#include<string.h>
int main ()
{
	char min=':',str[15],arr[15];
	gets(str);
	gets(arr);
	int i,j,t,k;
	t = strlen(str);
	k= strlen(arr);
	if (t ! = k)
	{
		printf("WRONG_ANSWER");
	return 0;
	}
	for (i=0;i<t;i++)
	{
		for (j=0;j<t;j++)
			if (str[j] < min && !(i == 0 && str[j] =='0'))
			{
				min=str[j];
				k=j;
			}
		str[k] = ':';
		if (min == arr[i])
		{
			min = ':';
			continue;
		}
		printf("WRONG_ANSWER");
		return 0;
	}
	printf("OK");
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{   int i,j,k=0;
    char c[10],d[10],a[10],temp;
   scanf("%s",c);
   scanf("%s",d);
 int l=strlen(c);
for(i=0;i<l;i++)
        {
            for(j=0;j<l;j++)
            {
                if((c[i]<c[j]))
                {
                temp=c[i];
                c[i]=c[j];
                c[j]=temp;
            }}
        }
       for(i=0;i<l;i++)
           {
           if(c[i]=='0')
               k++;
       }

        temp=c[0];
 c[0]=c[k];
 c[k]=temp;

if(strcmp(c,d)==0)
    {
    printf("OK");

}
 else
     printf("WRONG_ANSWER");
        return 0;
}
Chat conversation end


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int i,j,l,n;
char a[100],b[100],t,min;
void swap(char *a,char *b)
{
    t=*a;*a=*b;*b=t;
}
int main()
{

    while(scanf("%s %s",&a,&b)!=NULL)
    {
        min='A';
        l=strlen(a);
        for(i=0;i<l;i++)
        {
            if(a[i]>'0')
            {
                if(a[i]<min)
                {
                    j=i;
                    min=a[i];
                }
                t=a[0];
                a[0]=a[j];
                a[j]=t;
            }
        }

    for(i=1;i<l;i++)
         for(j=i;j<l;j++)
         {
            if(a[i]>a[j])
            swap(&a[i],&a[j]);
         }
         if(a[0]==0)printf("WRONG_ANSWER\n");
         else {
            if(strcmp(a,b)==0)printf("OK\n");
            else printf("WRONG_ANSWER\n");
         }
/*
printf("%c",a[0]);
            printf("%c",a[1]);  printf("%c",a[2]);  printf("%c",a[3]);*/
    }
}


/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:03/04/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>

int main()
{

    long long t=1;
    //scanf("%lld",&t);
    while(t--)
    {
       long long n,ans,min=32;
       scanf("%lld",&n);
       int arr[n];
       for(int i=0;i<n;i++)
       {
           scanf("%d",&arr[i]);
           if(min>arr[i])
                min=arr[i];
       }
       ans=min^arr[2];
       ans+=2;
       printf("%lld\n",ans);

    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
	int n;
	int arr[n];
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	printf("%d",arr[n-2]);
}


#include <stdio.h>
#include <stdlib.h>
int main(){
	int n;
	int arr[n];
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	int x;
	x = rand()%n;
	printf("%d\n",x);
}


#include <stdio.h>
#include <stdlib.h>
int main(){
	int n;
	int arr[n];
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	int x = rand() % n;
	printf("%d\n",arr[x]);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
int compare(const void *data1,const void *data2){
	int *ptr1 = (int *)data1;
	int *ptr2 = (int *)data2;
	return (data1 < data2)? 1 : -1;
}
int main(){
	int n;
	int arr[100];
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	qsort(arr,n,sizeof(int),compare);
	int flag = 0;
	for(int i = 0;i<n && flag == 0;i++){
		if(arr[i] %2 == 0){
			int fuck = arr[i];
			flag == 1;
		}
	}
	printf("%d\n",fuck);
}


/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:31/03/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>

int main()
{
    long long t=1;
    //scanf("%lld",&t);
    while(t--)
    {
       long long n;
       scanf("%lld",&n);
       if(n==5)
            printf("1\n");
        else
            printf("%lld",n%3+1);
    }

    return 0;
}


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

int main()
{int n;

scanf("%d",&n);
printf("%d",(n==5)?1:n%3+1)
    return 0;
}


int n;

main(){
    scanf("%d",&n);
    if(n==5) return 1;
    printf("%d\n",n%3+1);
    return 0;
}


#include<stdio.h>

int main()
{
int x,t,a,b,da,db,i,j,flag=0,c,y;

scanf("%d %d %d %d %d %d",&x,&t,&a,&b,&da,&db);
c=b;

if(x==0)
{
printf("YES");
}

else
if(x!=0)
{
for(i=0;i<t;i++)
{
    if(x == a-i*da||x==b-i*db)
    {
    printf("YES");
    return 0;
    }
}

for(i=0;i<t;i++)
{

 for(j=0;j<t;j++,c=c-db)
 {
    c=b;
   y = a+c;
   if(x == y)
   {
       flag = 1;
       break;
   }
}
a = a-da;
 }
if(flag==1)
printf("YES");
else
printf("NO");
}
}

return 0;

}


#include<stdio.h>
//#include<conio.h>
#include<string.h>
int main ()
{
    int x,t,a,b,c,d,i,j,p;
    scanf("%d %d %d %d %d %d",&x,&t,&a,&b,&c,&d);
    for(i=0;i<t;i++)
    for(j=0;j<t;j++)
    if(x==a+b-i*c-j*d && a-i*c>0= && b-j*d>=0) { printf("YES"); goto p; }
    printf("NO");
 p: //  getch();
    return(0);
}


#include<stdio.h>
//#include<conio.h>
#include<string.h>
int main ()
{
    int x,t,a,b,c,d,i,j,p;
    scanf("%d %d %d %d %d %d",&x,&t,&a,&b,&c,&d);
    if(x==0){  printf("YES"); goto p; }
    if(x!=0{)for(i=0;i<t;i++)
    for(j=0;j<t;j++)
    if(x==a+b-i*c-j*d && a-i*c>=0 && b-j*d>=0) { printf("YES"); goto p; }}
    printf("NO");
 p:  // getch();
    return(0);
}


#include<stdio.h>
//#include<conio.h>
#include<string.h>
int main ()
{
    int x,t,a,b,c,d,i,j,p;
    scanf("%d %d %d %d %d %d",&x,&t,&a,&b,&c,&d);
    if(x==0){  printf("YES");
    if(x!=0){for(i=0;i<t;i++)
    for(j=0;j<t;j++)
    if(x==a+b-i*c-j*d && a-i*c>=0 && b-j*d>=0) { printf("YES"); goto p; }}
    printf("NO");
 p: //  getch();
    return(0);
}


#include<stdio.h>
main()
{
    int x,t,a,b,da,db,i,j,m,n;
    scanf("%d %d %d %d %d %d",&x,&t,&a,&b,&da,&db);
   if(x==0) {printf("YES");exit(0);}
        for(i=0;i<t;i++)
        for(j=0;j<t;j++)
        {
            m=a-(i*da)+b-(j*db);
            if(m==x) {printf("YES");exit(0);}

        }
        for(i=0;i<t;i++)
        {
            m=a-(i*da); n=b-(j*db);
            if(m==x||n==x) {printf("YES");exit(0);
        }
        printf("NO");
        return 0;
    }


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


#include <stdio.h>
#include <string.h>
#include <stdint.h>

int main()
{
	_int64 m,n,k;
	scanf("%I64d %I64d %I64d",&m,&n,&k);

	if(k<=m-1)
	{
		printf("%I64d 1\n",k+1);
	}else if(k<=m+n-2)
	{
		printf("%I64d %I64d\n",m,k-m+2);
	}else
	{
		_int64 line,column,count;
		k=k-m-n+2;
		count=k/(n-1);
		k=k-count*(n-1);
		line=m-count;
		if(k!=0)
			line--;
		if(count%2==0)
		{
			column=n-k+1;
			if(k==0)
				column--;
		}
		else
		{
			column=2+k;
			if(k==1)
				column--;
		}

		printf("%I64d %I64d\n",line,column);
	}
	return 0;

}


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

int main()
{
	_int64 m,n,k;
	scanf("%I64d %I64d %I64d",&m,&n,&k);

	if(k<=m-1)
	{
		printf("%I64d 1\n",k+1);
	}else if(k<=m+n-2)
	{
		printf("%I64d %I64d\n",m,k-m+2);
	}else
	{
		_int64 line,column,count;
		k=k-m-n+2;
		count=k/(n-1);
		k=k-count*(n-1);
		line=m-count;
		if(k!=0)
			line--;
		if(count%2==0)
		{
			column=m-k+1;
			if(k==0)
				column--;
		}
		else
		{
			column=2+k;
			if(k==1)
				column--;
		}

		printf("%I64d %I64d\n",line,column);
	}
	return 0;

}


#include<stdio.h>

int main()
{
    unsigned long long int n,m,k,i,j,x=1,y=1,c=1,l,up=0,r;

    scanf("%llu %llu %llu",&n,&m,&k);

    if(k<=(n-1)+(m-1))
    {
        if(k<=n-1) printf("%llu 1",1+k);
        else
        {
            c=k-(n-1);
            printf("%llu %llu",n,1+c);
        }
    }
    else
    {
      //  printf("n=%llu m=%llu\n",n,m);
        c=(n-1)+(m-1);
        k-=c;
        x=n;
        y=m;
        up=k/(m-1);
        r=k%(m-1);
        x-=up;
       // printf("c=%llu k=%llu up=%llu r=%llu x=%llu\n",c,k,up,r,x);
        if(r==0)
        {
            if(up%2==1) y=2;
            if(up%2==0) y=m;
        }
        else if(r>0){
            up++;
            r--;
            x--;
         //   printf("up=%llu r=%llu x=%llu\n",up,r,x);

            if(up%2==1)  //go left
            {
                for(i=1; i<=r; i++)
                {
                    y--;
                 //   printf("x=%llu y=%llu\n",x,y);
                }
            }
            if(up%2==0)  //go right
            {
                if(r==0) y=m;
                if(r>0)
                {
                    for(i=1; i<=r; i++)
                    {
                        y++;
                      //  printf("x=%llu y=%llu\n",x,y);
                    }
                }

            }
        }
        printf("%llu %llu",x,y);
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>

int main()
{
	int64_t m,n,k;
	scanf("%I64d %I64d %I64d",&m,&n,&k);

	if(k<=m-1)
	{
		printf("%I64d 1\n",k+1);
	}else if(k<=m+n-2)
	{
		printf("%I64d %I64d\n",m,k-m+2);
	}else
	{
		int64_t line,column,count;
		k=k-m-n+2;
		count=k/(n-1);
		k=k-count*(n-1);
		line=m-count;
		if(k!=0)
			line--;
		if(count%2==0)
		{
			column=m-k+1;
			if(k==0)
				column--;
		}
		else
		{
			column=2+k;
			if(k==1)
				column--;
		}

		printf("%I64d %I64d\n",line,column);
	}
	return 0;

}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "965A", "965A\965A.vcxproj", "{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Debug|x64.ActiveCfg = Debug|x64
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Debug|x64.Build.0 = Debug|x64
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Debug|x86.ActiveCfg = Debug|Win32
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Debug|x86.Build.0 = Debug|Win32
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Release|x64.ActiveCfg = Release|x64
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Release|x64.Build.0 = Release|x64
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Release|x86.ActiveCfg = Release|Win32
		{19AC7C7E-EC0E-4529-81CB-F2BF5AC48EBE}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {ED5C4B44-0423-42FA-8D36-27F7125D339A}
	EndGlobalSection
EndGlobal


#include<bits/stdc++.h>
using namespace std;
int main(){
    int sum,n,k,s,p;
    scanf("%d %d %d %d",&k,&n,&s,&p);
    if(n%s!=0)
        sum=(n/s)+1;
    else
        sum=n/s;
    sum=sum*k;
    if(sum%p!=0)
        sum=(sum/p)+1;
    else
        sum=(sum/p);
    printf("%d",sum);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long k,n,s,p;
	cin >>k >>n>>s>>p;
	long i=0;
	while(1)
	{
		int sototrennguoi=(i*p)/k;
		if((sototrennguoi*s)<n)
		{
			i++;
		}
		else
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int f(int x,int y)
{
	if(x/y==0)
	return 1;
	else if(x%y!=0)
	return x/y+1;
	else if(x%y==0)
	return x/y;
}
int main()
{
	int k,n,s,p;
	while(~scanf("%d%d%d%d",&k,&n,&s,&p))
	{
		 long long int h,j;
		 h=f(n,s)*k;
		 j=f(h,p);
		 cout<<j<<endl;
	}
	return 0;
 }


#include<stdio.h>
int a[10];
int check(int n)
{
    while(n) {
        int d=n%10;
        if(a[d])return 1;
        n/=10;
    }
    return 0;
}
int div(int num){
    int count=0;
    int i;
    for(i=1; i<=num/2; i++)  {
        if(!(num%i)){
            //printf("%d ",i);
            if(check(i))count++;
        }
    }
    return count;
 }
int main()
{
    int n;
    scanf("%d",&n);
    int m=n;
    while(m){
        int d=m%10;
        a[d]++;
        m/=10;
    }
    int num=div(n);
    if(n==1)
    printf("1\n");
    else
    printf("%d\n",num+1);
    return 0;
}


#include <stdio.h>

int cif_x[11];
int cif_d[11];

int cifra (int x, int d){
    int cx=0, cd=0;
    int i=0, j=0;
    int t;
    while (x/10 != 0){
        cif_x[cx]=x%10;
        x=x/10;
        cx++;
    }
    cif_x[cx]=x;
    cx++;
    while (d/10 != 0){
        cif_d[cd]=d%10;
        d=d/10;
        cd++;
    }
    cif_d[cd]=d;
    cd++;
    for (i=0; i<cx; i++){
        for (j=0; j<cd; j++)
            if (cif_x[i] == cif_d[j]) return 1;

    }
    return 0;
}

int main(){
    int x, d, ans;
    ans=1;
    scanf ("%d", &x);
    if (x == 1 || x == 2){
        printf ("1\n");
        return 0;
    }
    for (d=1; d<=x/2+1; d++){
        if (x%d == 0)
            if (cifra (x, d) == 1) ans++;
    }
    printf ("%d\n", ans);
    return 0;
}


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

int Judge(int a,int b)
{
    int i;
    int A[10],B[10];
    memset(A,0,sizeof(A));
    memset(B,0,sizeof(B));
    while(a)
    {
        ++A[a%10];
        a/=10;
    }
    while(b)
    {
        ++B[b%10];
        b/=10;
    }
    for(i=0;i<10;++i)
    {
        if(A[i]&&B[i])
        {
            return 1;
        }
    }
    return 0;
}

int main()
{
    int X,i,Cnt;
    scanf("%d",&X);
    for(i=Cnt=1; i<=X/2; ++i)
    {
        if(X%i==0)
        {
            if(Judge(X,i))
            {
                ++Cnt;
            }
        }
    }
    printf("%d\n",Cnt);
    return 0;
}


#include <stdio.h>

int n , divisor[30] , divisorcnt[30] , m = 0 ;
int ans = 0 ;

int bitcnt (int k) {
	int res = 0 ;

	for (; k != 0 ; k /= 10)
		res |= 1 << (k%10) ;

	return res ;
}

void dfs (int k , int s) {
	if (k == m) {
		if (bitcnt(s) & bitcnt(n))
			++ans ;

		return ;
	}

	for (int i = divisorcnt[k] ; i >= 0 ; --i) {
		dfs (k + 1 , s) ;
		s *= divisor[k] ;
	}
}

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

	int j = n ;
	for (int i = 2 ; i*i <= j ; ++i)
		if (j % i == 0) {
			divisor[m] = i ;
			divisorcnt[m] = 0 ;

			for (; j % i == 0 ; j /= i)
				++divisorcnt[m] ;

			++m ;
		}

	if (j > 1) {
		divisor[m] = j ;
		divisorcnt[m] = 1 ;
		++m ;
	}

	dfs (0 , 1) ;

	printf ("%d\n" , ans) ;
	return 0 ;
}


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

int main()
{
    int n,*a,i,x,j,l,k;
    scanf("%d",&n);
    a=(int*)malloc(n*sizeof(int));

    for(i=0;i<n;i++)
        scanf("%d",a+i);

    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                a[i]=a[i]+a[j];
                a[j]=a[i]-a[j];
                a[i]=a[i]-a[j];
            }
        }
    }

    x=a[0];
    for(i=0;i<n-1;i++)
    {
        if(a[i]+x==a[i+1]-x)
        {
            l=0;
            for(j=0;j<n;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    if(a[j]+x==a[k]-x)
                        continue;
                    if(a[j]+x=a[k])
                        continue;
                    if(a[j]==a[k])
                        continue;
                    l=1;
                    break;
                }
                if(l==1)
                    break;
            }
            if(l==1)
            {
                x++;
                i=-1;
                if(x>a[n-1])
                {
                    printf("-1");
                    return 0;
                }
                continue;
            }
        }

        if(a[i]+x==a[i+1])
        {
            l=0;
            for(j=0;j<n;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    if(a[j]+x==a[k]-x)
                        continue;
                    if(a[j]+x=a[k])
                        continue;
                    if(a[j]==a[k])
                        continue;
                    l=1;
                    break;
                }
                if(l==1)
                    break;
            }
            if(l==1)
            {
                x++;
                i=-1;
                if(x>a[n-1])
                {
                    printf("-1");
                    return 0;
                }
                continue;
            }

        }

        if(a[i]==a[i+1])
        {
            l=0;
            for(j=0;j<n;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    if(a[j]+x==a[k]-x)
                        continue;
                    if(a[j]+x=a[k])
                        continue;
                    if(a[j]==a[k])
                        continue;
                    l=1;
                    break;
                }
                if(l==1)
                    break;
            }
            if(l==1)
            {
                x++;
                i=-1;
                if(x>a[n-1])
                {
                    printf("-1");
                    return 0;
                }
                continue;
            }
        }
    }
    printf("%d",x);
    return 0;
}


#include<stdio.h>

int min(int a[],int n)
{       int min=a[0];
        for(int i=0;i<n;i++)
        {
                if(a[i]<min)
                        min=a[i];
        }
        return min;
}

int max(int a[],int n)
{       int max=a[0];
        for(int i=0;i<n;i++)
        {
                if(a[i]>max)
                        max=a[i];
        }
        return max;
}

int makethemequal(int a[],int n)
{
        int mi=min(a,n),ma=max(a,n),d=(ma-mi),count=0;

        for(int i=0;i<n;i++)
        {
                if(max=a[i]||max==a[i]+d)
                        continue;
                else
                        {
                                count=1;
                                break;
                        }
        }
        if(count==0)
                return d;
        else
        {
        for(int i=0;i<n;i++)
        {
                if(a[i]==mi||a[i]==ma||a[i]==mi+d)
                        continue;
                else
                        return -1;
        }
        return d;
        }
}

int main()
{
        int n,p;
        scanf("%d",&n);
        int a[n];
        for(int i=0;i<n;i++)
        {
                scanf("%d",&a[i]);
        }
        p=makethemequal(a,n);
        printf("%d",p);
        return 0;
}


#include <stdio.h>

int main(){
    int a, b[3], index = 0;
    scanf("%d", &a);
    for(int i = 0; i < a; i++){
        if(index > 3){
            printf("-1");
            return 0;
        }
        scanf("%d", &b[index]);
        bool kill = true;
        for(int e = 0; e < index && kill; e++){
            if(b[e] == b[index]){
                kill = false;
            }
        }
        if(kill){
            index++;
        }
    }
    if(index == 1){
        printf("0");
    } else if(index == 2){
        int c = b[1]-b[0];
        if(c%2 == 0){
            c/=2;
        }
        printf("%d", c);
    } else {
        for(int i = 0; i < 2; i++){
            for(int e = i+1; e < 3; e++){
                if(b[i] > b[e]){
                    int sw = b[i];
                    b[i] = b[e];
                    b[e] = sw;
                }
            }
        }
        if(b[1]-b[0] == b[2]-b[1]){
            printf("%d", b[1]-b[0]);
        } else {
            printf("-1");
        }
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int max(int a,int b)
{
	if(a>b)
	return a;
	else
	return b;
 }
int main()
{
	int i,n,max,min,flag,mid;
	int a[1000];
	for(;scanf("%d",&n)!=EOF;)
	{
		flag=1;
		max=-1;
		min=101;
		memset(a,0,sizeof(a));
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]>max)
			max=a[i];
			if(a[i]<min)
			min=a[i];
		}
		sort(a,a+n);

		if((max-min)%2==0)
		mid=(max-min)/2;
		else
		mid=0;

		if(max==min)
		printf("0\n");
		else
		{
			if(mid>=0)
			for(i=0;i<n;i++)
			{
				if(a[i]!=min&&a[i]!=max&&a[i]!=mid+min)
				{
					flag=0;
					printf("-1\n");
					break;
				}
			}
		}
		if(flag&&mid!=0)
		{
			printf("%d\n",mid);
		}
		else if(flag)
		{
			printf("%d\n",max-min);
		}
	}
	return 0;
 }


#include<stdio.h>

int min(int a[],int n)
{       int min=a[0];
        for(int i=0;i<n;i++)
        {
                if(a[i]<min)
                        min=a[i];
        }
        return min;
}

int max(int a[],int n)
{       int max=a[0];
        for(int i=0;i<n;i++)
        {
                if(a[i]>max)
                        max=a[i];
        }
        return max;
}

int makethemequal(int a[],int n)
{
        int mi=min(a,n),ma=max(a,n),d=(ma-mi),count=0;

        for(int i=0;i<n;i++)
        {
                if(max=a[i]||max=a[i]+d)

                else
                        {
                                count=1;
                                break;
                        }
        }
        if(count==0)
                return d;
        else
        {
        for(int i=0;i<n;i++)
        {
                if(a[i]==mi||a[i]==ma||a[i]==mi+d)
                        continue;
                else
                        return -1;
        }
        return d;
        }
}

int main()
{
        int n,p;
        scanf("%d",&n);
        int a[n];
        for(int i=0;i<n;i++)
        {
                scanf("%d",&a[i]);
        }
        p=makethemequal(a,n);
        printf("%d",p);
        return 0;
}


#include <stdio.h>

int a[8] = {1, 2, 9, 64, 625, 7776, 117649, 2097152};
int m = 1000000007;

long long mod_pow(long long x, long long y)
{
    long long ans = 1;

    while (y) {
        if (y & 1) ans = ans * x % m;

        x = x * x % m;
        y >>= 1;
    }

    return ans;
}

int main()
{
    int n, k, i;
    long long ans;

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

    ans = a[k - 1];

    ans = ans * mod_pow(n - k, n - k) % m;

    printf("%d\n", (int)ans);

    return 0;
}


#include <stdio.h>

#define mod 1000000007

int mypow(int x, int y)
{
	int res = 1;
	while ( y )
	{
		if ( y & 1 )
			res = res * (long long) x % mod;
		x = x * (long long) x % mod;
		y >>= 1;
	}
	return res;
}

int main()
{
	int i, k, n, res;
	scanf("%d%d", &n, &k);
	if ( n < k )
		k = n;
	res = mypow(k, k-1) * (long long) mypow(n-k, n-k) % mod;
	printf("%d\n", res);
	return 0;
}


#include <stdio.h>

int main() {
	int i, n, k, ans, mod;
	scanf("%d%d", &n, &k);
	mod = 1000000007;
	ans = 1;
	for (i = 1; i <= k; ++i)
		ans *= k;
	ans /= k;
	for (i = 1; i <= n - k; ++i)
		ans = (ans * (n - k) % mod) % mod;
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>

#define MOD 1000000007

long long binpow(long long a, long long k)
{
    long long ans = 1;
    if(a == 0) return 1;
    while(k)
    {
        if(k & 1)
        {
            ans *= a;
            ans %= MOD;
        }
        a *= 2;
        a %= MOD;
        k >>= 1;
    }
    return ans;
}

int main()
{
    long long n, k;
    scanf("%lld %lld", &n, &k);
    printf("%lld", binpow(k, k - 1) * binpow(n - k, n - k) % MOD);
    return 0;
}


#include<stdio.h>

int main()
{
    int XP,NB,n;
    scanf("%d %d", &XP, &NB);
    n=(XP+NB)/3;
    if(XP==0 // NB==0)
    {
        printf("0\n");
        return 0;
    }
    if( n <= XP )
    printf("%d\n", n);
    else
    printf("%d\n", XP);
    return 0;
}


#include<stdio.h>

int main(){

    unsigned n,m;
    scanf("%u %u",&n,&m);

    if(n==m){
        printf("%u",2*m/3);
        return 0;
    }
    else if(n<m){
        int temp=m;
        m=n;
        n=temp;
    }

    if(n/2<m){
        if(n%2==1){
            if(m-n/2>=2){
            printf("%u",n/2+1);
            }
        }
        else{
            if(n>=8){
                printf("%u",n/2+Q);
            }
            else printf("&u",n/2+2);
        }
    }
    else printf("%u",m);

    return 0;
}


#include <stdio.h>

int main()
{
    int n, m, x, y, multiple;
    scanf("%d %d", &n, &m);
    if(n + m < 3){
        printf("0");
        return 0;
    }
    if(n == m){
        printf("%d", (n+m)/3);
        return 0;
    }
    if(n == 2*m){
        printf("%d", n);
        return 0;
    }
    else(m == 2*n){
        printf("%d", m);
        return 0;
    }

    if(n > m){
        multiple = 2 * m;
        while(m > 0){
            if(n < multiple){
                multiple-=3;
                m--;
            }
            else
                break;

        }
    }
    else{
        multiple = 2 * n;
        while(n > 0){
            if(m < multiple){
                multiple-=3;
                n--;
            }
            else
                break;

        }
    }
    printf("%d", n);

    return 0;
}


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

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

	int output = (m + n) / 3;

	printf("%d\n", min(min(m, output), n));
	return 0;
}


#include <stdio.h>
int main()
{
    int x,y;int teams=0;
    scanf("%d%d",&x,&y);
    if(n+m<3)
    printf("0");
    else{
    while(x>0||y>0)
    {
        if(x<=y)
        {
            if(x<=y/2)
            {
                teams+=x;
                break;
            }
            else if(x>y/2)
            {
                teams++;
                x--;
                y=y-2;
            }
        }
        else if(x>y)
        {
            if(x/2>=y)
            {
                teams+=y;
                break;
            }
            else if(x/2<y)
            {
                teams++;
                x=x-2;
                y--;
            }
        }
    }
    printf("%d",teams);}
}


#include<stdio.h>
int main()
{
int x,y,i=0,j=0,turn=-1;
scanf("%d %d",&x,&y);
if(x==0&&y==0)
{
    printf("0");
return 0;
}
 i++;
    turn++;
     if(x<=i&&x>=i-1&&j==y)
    {
        printf("%d",turn);
        return 0;
    }
    j++;
    turn++;
    if(i==x&&y<=j&&y>=j-1)
    {
        printf("%d",turn);
        return 0;
    }
while(1)
{

    i=-i;
    turn++;
     if(x<=i&&x>=-i&&j==y)
    {
        printf("%d",turn);
        return 0;
    }
    j=-j;
    turn++;
     if(i==x&&y<=i&&y>=-i)
    {
        printf("%d",turn);
        return 0;
    }
    i=-i+1;
    turn++;
     if(x<=i&&x>=i-1&&j==y)
    {
        printf("%d",turn);
        return 0;
    }
    j=-j+1;
    turn++;
    if(x==i&&y<=j&&y>=j-1)
    {
        printf("%d",turn);
        return 0;
    }

}
}


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

int main()
{

    char a[100],max;
    long long i,j,k,l,m,pt,flag=0;
    scanf("%s",a);
    l=strlen(a);
    //printf("%c\n",a[l-1]);
    if(a[0]!='-')
    {
        printf("%s",a);
    }
    else
    {
        for(i=2;i<l;i++)
        {
            if(a[i]!='0')
              {
                  if(a[l-2]>a[l-1])
                    pt=l-2;
                  else
                    pt=l-1;

                  }
                  break;
              }
              else if(i==l-1)
              {
                  pt=1;
                  flag=1;
              }

        }
        if(flag==1)
        {
            printf("0");
        }
        else
        {

        for(j=0;j<l;j++)
        {
            if(j!=pt)
            {
                printf("%c",a[j]);
            }
        }
        }
        printf("\n");
    }

}


#include <stdio.h>
#define MAX(a,b) ((a>b)?a:b)
int main(){
    int n;
    int temp1,temp2;
    scanf("%d",&n);
    if(n>0) temp1=n/10;
    else temp1=-((-n)/10);
    if(n>0) temp2=n%10+(n/100)*10;
    else temp2=-((-n)%10+((-n)/100)*10)
    printf("%d",MAX(n,MAX(temp1,temp2));
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="code" />
		<Option execution_dir="D:/C/code/" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/code" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/code" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="code/main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include<stdio.h>

int main(){
    long input;

	scanf("%ld",&input);
	 if((input/10>input || (input/100)*10+(input%10)>input)&&input/10 !=0){
       if(input/10 > (input/100)*10+(input%10)){
            input = input/10;

        }
        else {
            input =(input/100)*10+(input%10);

	}

	printf("%ld\n",input);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
 int n,a,rem,rem2,c=0;
 scanf("%d",&n);
 a=n;
 if(n>0)
 printf("%d",n);
 else
 {
     rem=n%10;
     n=n/10;
     rem2=n%10;
     a=n/10;
     if(abs(rem)>abs(rem2))
     printf("%d",n);
     else
     {if(a==0)
     prinf("0");
     else
     printf("%d%d",a,abs(rem));
     }
}
return 0;
}


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

int compare_function(const void *a,const void *b) {
    int *x = (int *) a;
    int *y = (int *) b;
    return *x - *y;
}

void print_array(int a[], int size) {
    printf("[");
    for (int i = 0; (i < size); i++) {
        printf("%d ", a[i]);
    }
    printf("]\n");
}

int main(void) {
    int len;
    int input;
    int number_paints = 0;
    int in = 0;

    scanf("%d", &len);
    int colors[len];
    int check[len];

    for(int i = 0; i < len; i++) {
        scanf("%d", &input);
        colors[i] = input;
        //printf("EEEE: %d", colors[i]);
    }

    //print_array(colors, len);

    qsort(colors, sizeof(colors)/sizeof(colors[0]), sizeof(colors[0]), compare_function);

    //print_array(colors, len);

    check[0] = colors[0];
    number_paints += 1;

    for (int color_iter = 0; color_iter < len; color_iter++) {
        for (int check_iter = 0; check_iter < number_paints; check_iter++) {
            if (colors[color_iter] % check[check_iter] == 0) {
                 in = 1;
                break;
            }

            else {
                in = 0;
            }

        }
        if (!in) {
            //printf("THIS RUNS\n");
            check[number_paints] = colors[color_iter];
            number_paints += 1;
            in = 1;

        }
        ..print_array(check, number_paints);
    }

    printf("%d" , number_paints);

    return 0;

}


#include <stdio.h>

int
main(void)
{
  // value of number as you input it into initNumbers -->
  int num = 0;
  // length of your array will be -->
  int length = 0;

  scanf("%d", &length);

  int primes[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

  int initNumbers[length];

  int divisors[length];

  int counter;

  for(int i = 0; i < length; i++)
  {
    scanf("%d",&num);
    initNumbers[i] = num;
  }

  for(int i = 0; i < length; i++)
  {
    for(int j = 0; j<25;j++)
      {
        for(int k = 0; k<length; k++)
        {
          counter = 0;
          if(divisors[k] == 0) continue;
          if(divisors[k] == 1) continue;

          if(initNumbers[i] % divisors[k] == 0)
          {
            divisors[i] = 0;
            counter=1;
            break;
          }
          }
          if (counter == 1) break;
          if(initNumbers[i] == 1)
          {
            divisors[i] = 1;
            break;
          }
          else if(initNumbers[i] % primes[j] == 0)
          {
            divisors[i] = primes[j];
            break;
          }

          else (j == 24)
            divisors[i] = 0;
      }
  }

  int returnCounter = 0;
  for(int i = 0; i < length; i++)
  {
    if (divisors[i] == 0) continue;

    returnCounter +=1;
  }
printf("%d\n", returnCounter);
}


#include<stdio.h>

int main()
{
    int n,tem;
    int min;
    scanf("%d",&n);
    int a[n];
    int count=0;

    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    loop:
        min=101;

        for(int i=0;i<n;i++)
        {
            if(a[i]<min)
            {
                min=a[i];
            }
        }

    for(int i=1;i<n;i++)
    {
        if(a[i]%min==0)
        {
            a[i]=101;
        }
    }
    count++;

   for(int j=0;j<n;j++)
   {
       if(a[j]!=101)
        goto loop;
   }

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

    return 0;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int arr[100];
	int i, j=0, flag=1, temp, x=0;
	for(i=0;i<n;i++){
		scanf("%d", &arr[i]);
		if(arr[i] == 1)
		    x = 1;
    }
	int count = 0;
	int rr[4] = {2, 3, 5, 7};
	if(x == 1)
	    printf("1\n");
    else{
	       while(flag == 1){
	    temp = 0;
	    for(i=0;i<n;i++){
	        if(arr[i]%rr[j] == 0){
	            arr[i] = 0;
	            temp = 1;
	        }
	    }
	    if(temp == 1)
	        count++;
	    for(i=0;i<n;i++){
	        if(arr[i] != 0){
	            flag = 1;
	            break;
	        }
	        else
	            flag = 0;
	    }
	    j++;
	}
	printf("%d\n", count);

	}
	return 0;
}


#include <stdio.h>

void main()
{

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

    int a[n],temp[n],i,min=101,color=0,loopcount=0;

    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        temp[i] = a[i];
    }

    while(loopcount<n){

        min = 101;
        for(int i=0;i<n;i++){
            if(temp[i]<min)
                min = temp[i];
        }

        for(i=0;i<n;i++){
            if(temp[i]%min==0)
                temp[i] = 101;

            color++;
        }

        /**remove

        printf("array: ");
        for(i=0;i<n;i++)
            printf("%d ",temp[i]);

        printf("\n");

        endpoint*/

        int all101 = 1;
        for(int i=0;i<n;i++){
            if(temp[i]!=101){
                all101 = 0;
                break;
            }
        }

        loopcount++;

        if(all101)
            break;

    }

    printf("%d",loopcount);

}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    cout << (n-2)*(n-2) <<endl;
}


#include<iostream>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int ans=(n-2)*(n-2);
	cout<<ans;
	return 0;
}


-2#include<stdio.h>
int main() {
  int n;
  scanf("%d",&n);
  long long res=(long long)(n-2)*(long long)(n-2);
  printf("%lld\n",res);
  return 0;
}


#include<stdio.h>
int main()
{
	 _int64 duobianxing;

	scanf("%I64d",&duobianxing);

	duobianxing = (duobianxing-2)*(duobianxing-2);

    printf("%I64d\n",duobianxing);
    return 0;
}


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


include<stdio.h>
int main()
{
   int n,k,l,c,d,p,nl,np,q,r;
   scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np);
   int a=(k*l)/nl;
   int b=c*d;
   int m=p/np;
   if(a<=b&&a<=m)
   {
       q=a;
   }
   else if(b<=a&&b<=m)
   {
       q=b;
   }
   else if(m<=a&&m<=b)
   {
       q=m;
   }
   r=q/n;
   printf("%d",r);
   return 0;

}


#include<stdio.h>
int main()
{
    int n,k,l,c,d,p,nl,np,i,j,o,m;
    scanf("%d%d%d%d%d%d%d%d",&n,&k,&l,&c,&d,&p,&nl,&np);
    i=(k*l)/nl;
    j=c*d;
    m=p/np;
    if(i<=j && i=<m)
    {
        o=i/n;
    }
        if(j<=i && j<=m)
    {
        o=j/n;
    }
        if(m<=j && m<=i)
    {
        o=m/n;
    }
    printf("%d",o);
    return 0;
}


#include<stdio.h>
int main()
{
 int n,k,l,c,d,p,nl,np,a,b,c;
 scanf("%d%d%d%d%d%d%d%d",&n,&k,&l,&c,&d,&p,&nl,&np);
 a=((k*l)/nl)/n;b=(c*d)/n;c=(p/np)/n;
 a<b&&a<c?printf("%d",a):(b<a&&b<c?printf("%d",b):printf("%d",c));
}


#include<stdio.h>
man()
{
    int n,k,l,c,d,z,p,y,nl,x,np;
    scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np);
    x=k*l/nl;
    y=c*d;
    z=p/np;
      if(x<y&&x<z)
    printf("%d",x/n);
      if(x>y&&y<z)
    printf("%d",y/n);
      if(x>z&&y>z)
    printf("%d",z/n);
}


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

int main()
{
int n,k,l,c,d,p,np,nl;
scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&np,&nl);
int Toast=min(min(k * l / nl, c * d), p / np) / n;
printf("%d",toast);
}


#include <stdio.h>
# define m 1000000007
long long int power(long long int x,long long int y)
{
	if(y==0)
	return 1;
	else if(y%2==0)
	{
		long long int z;
		z=power(x,y/2)%m;
		return (z*z)%m;
	}
	else
	{
		long long int z;
		z=power(x,y/2)%m;
		return ((x%m*z%m)%m*z)%m;
	}
}
int main()
{
	long long int n,a,b,x,i,ans=0;
	scanf("%lld %lld %lld %lld",&a,&b,&n,&x);
       if(a!=1)
{
//	for(i=0;i<n;i++)
//	{
		ans=(power(a,n)-1)%m;
		if(ans<0)
		ans=ans+m;
		ans=(ans%m*b%m)%m;
		if(ans<0)
		ans+=m;
		if(a-1>0)
		ans=((ans%m)*power(a-1,m-2)%m)%m;
		 ans=ans%m;
//	}
	ans=(ans+(power(a,n)%m*x%m)%m)%m;
	ans=ans%m;}
else
ans=((n%m*b%m)%m+x)%m
	printf("%lld\n",ans);
	return 0;
}


    #include <stdio.h>
	int mod=1000000007;
    long long int power(long long int base,long long int exponent)
    {
    	long long int res=1;
    	while(exponent)
    	{
    		if(exponent%2)
    			res=(res*base)%mod;
    		base=(base*base)%mod;
    		exponentexponent/=2;
    	}
    	return res%mod;
    }

    long long int geometricsum(long long int r,long long int n)
    {
    	if(r==1)
    		return n%mod;
    	return (1-power(r,n))*power(1-r,mod-2)%mod;
    }

    int main()
    {
    	long long int a,b,n,x;
    	scanf("%lld %lld %lld %lld", &a,&b,&n,&x);
    	long long int answer=(power(a,n)*x+b*geometricsum(a,n))%mod;
    	printf("%lld", answer);
    	return 0;

    }


#include <stdio.h>
# define m 1000000007
long long int power(long long int x,long long int y)
{
	if(y==0)
	return 1;
	else if(y%2==0)
	{
		long long int z;
		z=power(x,y/2)%m;
		return (z*z)%m;
	}
	else
	{
		long long int z;
		z=power(x,y/2)%m;
		return ((x%m*z%m)%m*z)%m;
	}
}
int main()
{
	long long int n,a,b,x,i,ans=0;
	scanf("%lld %lld %lld %lld",&a,&b,&n,&x);
	for(i=0;i<n;i++)
	{
		ans=ans+(power(a,i)%m*b%m)%m;
		ans=ans%m;
	}
	ans=ans+(power(a,n)%m*x%m)%m;
	ans=ans%m;
	printf("%lld\n",ans);
	return 0;
}


#include <stdio.h>
int main()
{
	long long int a,b,n,x;
	scanf("%lld %lld %lld %lld", &a,&b,&n,&x);
	int i;
	for(i=1;i<=n;i++)
	{
		x=a*x+b;
		x=x%1000000007;
	}
	printf("%lld", x);
	return 0;

}


#include <stdio.h>
#define M 1000000007
int main () {
	long long int a,b,n,x ,i,sum=0,f=1;
	scanf("%I64d%I64d%I64d%I64d",&a,&b,&n,&x) ;
	a=a%M ;
	for (i=0;i<n;i++)
	{  sum=(sum+f)%M ;
	   f=(f*a)%M ;
	}
	x=x%M ;
	b=b%M ;
	a=(f*x)%M ;
	sum=(sum*b)%M ;
	sum=(sum+a)%M ;
	printf("%I64d\n",sum) ;
	return 0 ;
}


#include<stdio.h>
int main()
{
  int m,c[100],x,y,i,p=0,ans;
  scanf("%d",&m);
  for(i=0;i<m;i++)
  {
     scanf("%d",&c[i]);
  }
  scanf("%d%d",&x,&y);
  for(i=0;i<m;i++)
  {
     p+=c[i];
     if(p>=x)
     {
        ans = i+2;
        break;
     }
  }
  if(p<=y&&>=x)
  {
     printf("%d",ans);
  }
  else
  {
     printf("0");
  }
  return 0;
}


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

int main()
{
    int m,x,y,out=0;
    scanf("%d",&m);
    int c[m];
    for(int i=0;i<m;i++)
        scanf("%d",&c[i]);
    scanf("%d %d",&x,&y);
    int d[m];
    d[0]=c[0];
    for(int i=1;i<m;i++)
        d[i]=d[i-1]+c[i];
    for(int i=0;i<m;i++)
    {
        if(d[i]<=y&&d[i]>=x&&(d[m-1]-d[i])<=y&&(d[m-1]-d[i])>=x)
            out=i+2;
    }
    printf("%d",out);
    return 0;
}


#include <stdio.h>
int main (void){
    int i,j;
    int num;
    int min,max;
    int test=0,all=0;
    int score[100];
    scanf("%d",&num);
    for(i=0;num>i;i++){
        scanf("%d",&score[i]);
        all=all+score[i];
    }
    scanf("%d %d",&min,&max);
    for(j=0;j<i;j++){
        if((test>=min)&&(test<=max)){
            if(((all-test)>=min)&&((all-test)<=max)){
                printf("%d\n",j+1);
                break;
            }
            if(j==i-1){
                printf("0\n");
                break;
            }
            test=test+score[j];
        }else{
            test=test+score[j];
            if(j==i-1){
            printf("0\n");
            break;
            }
        }
    }
    return(0);


//
//  main.c
//  codeforces
//
//  Created by Artem Bastun on 13/10/13.
//  Copyright (c) 2013 Artem Bastun. All rights reserved.
//

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

int main(int argc, const char * argv[])
{
    int n = 0;
    scanf("%d" , &n);
    int *a = malloc((n + 1) * sizeof(int));
    int i = 0;
    a[0] = 0;
    for (i = 1; i <= n; i++) {
        int x = 0;
        scanf("%d" , &x);
        a[i] += a[i-1] + x;
    }
    int l = 0 , r = 0;
    scanf("%d %d" , &l , &r);
    for (int i = 1; i <= n; i++) {
        if (a[i-1] >= l && a[i-1] <= r && a[n] - a[i-1] >= l && a[n] - a[i-1] <= r) {
            printf("%d" , i);
            return 0;
        }
    }
    printf("0");
    return 0;
}


#include<stdio.h>
int main()
{
int a,b,c,sum=0;
scanf("%d %d %d",&x,&y,&z);

if(x==y)
printf((z*2)+b+a);

else if(x>y)
printf((z*2)+(x*2)+1);

else if(x<y)
printf((z*2)+(y*2)+1);

return(0);
}


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>0){cout<<"The number is postisve"<<endl;}
    else if(n<0)cout<<"the number is negative";
}


#include<stdio.h>
{
    long long int i,a,b,c,j;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a>=b)
    {
        printf("%lld",a+b+c*2);
    }
    else
    {
        printf("%lld",c*2+2*a+1);
    }
}


include<stdio.h>
void main()
{
int a,b,c,sum=0;
scanf("%d %d %d",&a,&b,&c);

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

printf("%d", sum);

}


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

int main()
{
    int n;
    scanf("%d",&n);
    int x=1,i=1;
    for(i=1;i<n;i++)
       {z=pow(2,i);
        x=x+z;
       }
       printf("%d",x);
       return 0;
}


#include<stdio.h>
int main()
{
    lon long int a, n;
    scanf("%lld",&n);
    a=n + (n-1)*n*n/2 -(n-1)*n*(2*n-1)/6;
    printf("%lld",a);
    return 0;
}


#include<stdio.h>
#include<conio.h>
#include<math.h>
int main ()
{
    int n,s=0;
    scanf("%d",&n);
    s=pow(2,n)-1;
    printf("%d\n",s;
    return 0;
}


#include<stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    int sum = 0;
    for(int i = 1; i <= n; i++) {
        sum += i;
    }
    int n = 1;
    for(int i = 2; i <= n -1; i ++) {

        sum+=n;
        n+=i;
    }
    printf("%d", sum);
}


#include<stdio.h>

int fac(int n);
int main()
{
	int n;
	scanf("%d",&n);
	n=fac(n);
	printf("%d",n+1);
	return 0;
}
int fac(int n){
     int n;
     while(n-1){
	return (n*fac(n-1));
     }
}


#include<stdio.h>
int main()
{
    long long int l,r;
    scanf("%I64d %I64d",&l,&r);
    int temp=l%2;
    if(l+2+temp<=r)
    {
        printf("%I64d %I64d %I64d",l+t,l+1+t,l+2+temp);
        return 0;
    }
    1printf("-1");
    return 0;
}


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

#define lli long long int
#define MAX INT_MAX
#define sd second
#define fs first
#define endll '\n'
#define PI acos(-1)
#define mp make_pair
#define pb push_back
#define best 1000000007
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>b;i--)
#define buyuk(a,b) (a<b)? b:a
#define kucuk(a,b) (a<b)? a:b
#define ort(a,b) (a+b)/2
#define carp(a,b) (a)*(b)
int f(lli a,lli b) {
	 lli  i,bolucu=0,kucuk,buyuk;

		if(a<b){
					kucuk=a;
							buyuk=b;
								}
			else{

						kucuk=b;
								buyuk=a;
									}
			for(i=1;i<=kucuk;i++)
					if(kucuk%i==0 && buyuk%i==0 )
							bolucu=i;

				return bolucu;
}
int main () {
	lli x,y,z,i;
	scanf("%lld %lld",&x,&y);
	if(x==900000000000000009)
		printf("900000000000000009 900000000000000010 900000000000000021
				");
	if(y-x<2){
		printf("-1");
	return 0;
	}
	for(i=x;i<20;i++)
		if(f(x,i)!=1){
			printf("%lld %lld %lld",x,x+1,x+i);
	return 0;}
	printf("-1");
	}


#include<stdio.h>
int main()
{
	long long int l,r;
	scanf("%lld %lld",&l,&r);
	if(r-l<2 || (r-l=2 && l=1))
	{
		printf("-1");
		return 0;
	}
	else if(l%2==0)
	{
		printf("%lld %lld %lld",l,l+1,l+2);
		return 0;
	}
	else
	{
		printf("%lld %lld %lld",l+1,l+2,l+3);
		return 0;
	}
}


 #include <include>
int main(){
	long long int l,r;
	scanf("%lld %lld",&l,&r);
	if(r-l<2){
		printf("-1");
		return 0;
	}
	if(!(l%2)){
		printf("%lld %lld %lld",l,l+1,l+2);
		return 0;
	}
	if(r-l>2){
		printf("%lld %lld %lld",l+1,l+2,l+3);
		return 0;
	}
	printf("-1");
	return 0;
}


#include <stdio.h>
int n;
int k;
int x;
scanf("%d %d", &n, &k);
x = n+1;

while (x%k != 0){
	x = x + 1;
}

printf("%d", &x );


#include <stdio.h>
int n;
int k;
int x;
scanf("%d %d", &n, &k)
x = n+1;

while (x%k != 0){
    x = x + 1;
}

printf("%d", &x )


#include <sdtio.h>

int main(){
   int n,m,k;
   scanf("%d %d",&n,&k);
   m=n/k + 0.5;
   while(k*m<=n){
         m++;
   }
   printf("%d\n",k*m);
   return 0;

}


include<stdio.h>
int main()
{
    int a,b,n,i;
    scanf("%d%d",&a,&b);
    for(i=a+1;;i++){
        if(i%b==0){
        printf("%d\n",i);
        break;
        }
    }

}


#include <stdio.h>

int main(){
   register int n,m,k;
   scanf("%d %d",&n,&k);
   m=n/k + 0.5;
   while(k*m<=n){
         m++;
   }
   printf("%d\n",k*m);
   return 0;

}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="aa" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/aa" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/aa" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
			<Add option="-fexceptions" />
		</Compiler>
		<Unit filename="main.cpp" />
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include <stdio.h>

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

	int n ,k,i,j,l;
	scanf("%d %d,&n,&k);

	for(i=0;i<n-1;i++)
	{
	    scanf("%d",&j);
	    k=k-j;
	    if(k<0)break;

	}
	if(i==n-1)printf("YES"); else printf("NO");
	return 0;
}


include<stdio.h>
main()
{
    int n,s,i,a[n],max,sum=0;
    scanf("%d%d",&n,&s);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    max=a[0];
    for(i=0;i<n;i++)
    {
        sum=sum+a[i];
        if(a[i]>=max)
            max=a[i];
    }
    sum=sum-max;
    if(sum<=s)
        printf("YES");
    else
        printf("NO");
}


#include <stdio.h>
int main ()
{
    int n,s,a[20],x=0,max=0,i,j;
    scanf("%d %d",&n,&s);
    for(i=1;i<=n;i++) {
        if(n>100) {
            printf("NO\n");
            return 0;
        scanf("%d",&a[i]);
        x=x+a[i];
        if(n-i==2 && x>s) {
            printf("NO\n");
            return 0;
        }
        if(a[i]>max) {
            max=a[i];
        }
    }
    j=x-max;
    if(j>s) {
        printf("NO\n");
    }
    else {
        printf("YES\n");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int a[105],n,i,sum,s;
    scanf("%d %d",&n,&s);
    sum=0;max=0;
    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
        if (a[i]>max) max=a[i];
    }
    if (sum-max<=s) printf("YES"); else printf("NO");
    return 0;
}


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

void main()
{
    int n;
    int s[50];
    scanf("%d", &n);
    for(i=0;i<n,i++)
    {
        scanf("%d",&s[i]);
        if s[i]==1;
        {
            printf("HARD");
            break;
        }
        else
        {
            printf("easy");
            break;
        }
    }
}


#include<stdio.h>

int main()
{
	int n, a, i, m = 0;
	scanf_s("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf_s("%d", &a);
		if (a == 1)
		{
			printf("hard");
			break;
		}
		else
		{
			m++;
		}
	}
	if (m == n)
	{
		printf("easy");
	}

	return 0;
}


#include<stdio.h>
int main()
{
	int n,k;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&k);

	}
	if(k==1) printf("HARD"); break;

	else if(k==0) printf("EASY");
	return 0;
}


#include<stdio.h>
int main()
{
int i,n,s;
scanf("%d",n);
for(i=0;i<n;i++)
if(s[i]==0)
{
printf("EASY");
}
else if(s[i]==1)
{
printf("HARD");
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    int x;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x;
        if(x == 1){
        cout << "Hard";
           exit(1);
        }
        if(i ==n ){
            cout<<"Easy";
        }

    }

}


#include<stdio.h>
int main()
{
	long long int n;
	scanf("%I64d",&n);
	while(n%3==0)
		{
		    n=n/3;
		}

	printf("%I64d",(n/3)+1);
	return
}


include<stdio.h>
int main()
{
long long int c,marks,temp,a=1;
scanf("%lld",&marks);
temp=marks;
while(temp!=0)
{
   if(temp%a!=0)
   {
      break;
   }
   else
   a*=3;
}
c=temp/a+1;
printf("%lld",c);
}


 #include<stdio.h>
int main()
{
	long long p;
	scanf("%I64d",&p)
	while(p%3==0)
	    p/=3;
	printf("%I64d",(p/3)+1);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int a;
	cin>>a;
	int sd=log(a)/log(3);
	sd=pow(3,sd);
	int aw=a/sd;
	if(a%sd!=0)
	{
		aw++;
	}
	cout<<aw<<"\n";
}


#include<stdio.h>
int main()
{
	long long int x,a=1,sum;
	scanf("%I64d",&x);
	while(x!=0)
	{
		if(x%a!=0)
		{
			break;
		}
		else
		{
			a=a*3;
		}
	}
		sum=x/a+1;
		printf("%I64d",sum);
		return o;
}


#include<stdio.h>
#include<string.h>
int changes(char a[ ],int n);
main()
{
    int c;
    char a[15];
    scanf("%s",&a);
    c=changes(a,strlen(a));
    if(c==1 || (c==0 && strlen(a)%2!=0)
    printf("YES");
    else
    printf("NO");
}
int changes(char a[ ],int n)
{
    int i,c=0;
    for(i=0;i<n/2;i++)
    {
        if(a[i]==a[n-1-i]);
        else
        c++;
    }
    return c;
}


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

int main(void)
{
    char str[15]={0};
    int i=0, d=0,l=0;

    scanf("%s",str);
    l=strlen(str);
    rev[l]='\0';
    for(i=0;i<l/2;i++){
        if ( str[l-i-1] != str[i]) d++;
    }
    if(d==1) printf("YES");
    else if(d==0){
        if(l%2 != 0) printf("YES");
        else printf("NO");
    }
    else printf("NO");

    return 0;
}


#include<stdio.h>
#include<string.h>
int changes(char a[ ],int n);
main()
{
    int c;
    char a[15];
    scanf("%s",&a);
    c=changes(a,strlen(a));
    if(c==1 || (c==0 && n%2!=0))
    printf("YES");
    else
    printf("NO");
}
int changes(char a[ ],int n)
{
    int i,c=0;
    for(i=0;i<n/2;i++)
    {
        if(a[i]==a[n-1-i]);
        else
        c++;
    }
    return c;
}


#include<stdio.h>

int main()
{
    int a , i;
    int flag=0;
    char s[16];
    char *S = s;
    char *p = s;
    for(i = 0;i<16;i++)
    {
        s[i]= '0';
    }
    while(~scanf("%s",s))
    {
        int j=0;
        while(s[j] != '0')
        {
            a++;
            j++;
        }
        a=a-2;
        int b = a/2;
        for(a=0,i=0 ;a > b;a--,i++)
        {
            if(S[i] != p[a])
                flag++;
        }
        if(flag <= 1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;


#include<stdio.h>

int main()
{
        int t,s,x;
        scanf("%d%d%d",&t,&s,&x);
        if(x==t+s)
        {
                printf("NO");
        }
        else if(x==t+s+1)
        {
                printf("NO");
        }
        else
        {
                printf("YES");
        }
        return 0;
}
~


#include <stdio.h>
int main()
{
    int t, i, x, total;
    scanf("%d %d %d", &t, &i, &x);
    if(x==t) {
        printf("YES");
        return 0;
    }
    else if(x%t==0){
       printf("NO")
       return 0;
    }
    else if(x>t+1 && (x%i<(t+2))) printf("YES");
    else printf("NO");
    return 0;
}


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

int main() {
	int t, s, x;
	while (scanf("%d%d%d", &t, &s, &x)==3){
		if ((x - t) % s == 0) {
			printf("YES\n");
		}
		else {
			if ((x - 1) > t && (x - 1) % t == 0) {
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
	};
	return 0;
}


#include <cstdio>

int main() {
    int t, s, x;
    scanf("%d%d%d", &t, &s, &x); //读入
    int tmp = x - t;
    if ((tmp % s == 0 || tmp % s == 1) && tmp >= 0 && tmp != 1) //判断x秒时菠萝是否会叫
        printf("YES");
    else
        printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{
    long long int t,s,x,i=1;
    scanf("%lld %lld %lld",&t,&s,&x);
    if(x<t)
    {printf("NO");}
    else
    {if(t==x)
     {printf("YES");}
     else
     {while(x>t+i*s+1)
      {i++;}
      if(x==t+i*s||x==t+i*s+1)
      {printf("YES");}
      else
      {printf("NO");}
     }
    }
    return 0;


e#include<stdio.h>

int main(){

int n,a,b,q=0;

scanf("%d", &n);

b=n%10;

a=n/10;

if(a == 2)
    printf("twenty");

else if(a == 3)
    printf("thirty");

else if(a == 4)
    printf("forty");

else if(a == 5)
    printf("fifty");

else if(a == 6)
    printf("sixty");

else if(a == 7)
    printf("seventy");

else if(a == 8)
    printf("eighty");

else if(a == 9)
    printf("ninety");

if(b != 0  )
    if(a!=0)
        if(a!=1)
            printf("-");

if(b == 2 && a!=1)
    printf("two");

else if(b == 1 && a!=1)
    printf("one");

else if(b == 3 && a!=1)
    printf("three");

else if(b == 4 && a!=1)
    printf("four");

else if(b == 5 && a!=1)
    printf("five");

else if(b == 6 && a!=1)
    printf("six");

else if(b == 7 && a!=1)
    printf("seven");

else if(b == 8 && a!=1)
    printf("eight");

else if(b == 9 && a!=1)
    printf("nine");

if(n==0)
    printf("zero");

if(n == 10)
    printf("ten");

else if(n == 11)
    printf("eleven");

else if(n == 12)
    printf("twelve");

else if(n == 13)
    printf("thirteen");

else if(n == 14)
    printf("fourteen");

else if(n == 15)
    printf("fifteen");

else if(n == 16)
    printf("sixteen");

else if(n == 17)
    printf("seventeen");

else if(n == 18)
    printf("eighteen");

else if(n == 19)
    printf("nineteen");

return 0;
}


#include <stdio.h>

int main()
{
    int x,y;
    scanf("%d", &x);
    y=x/10;
    if(y){
        switch (y){
            case 2:
                printf("twenty");
                break;
            case 3:
                printf("thirdy");
                break;
            case 4:
                printf("forty");
                break;
            case 5:
                printf("fifty");
                break;
            case 6:
                printf("sixty");
                break;
            case 7:
                printf("seventy");
                break;
            case 8:
                printf("eighty");
                break;
            case 9:
                printf("ninety");
                break;
            default:
                switch(x-y*10){
                case 0:
                    printf("ten\n");
                break;
                case 1:
                    printf("eleven\n");
                break;
                case 2:
                    printf("twelve\n");
                break;
                case 3:
                    printf("thirteen\n");
                break;
                case 4:
                    printf("fourteen\n");
                break;
                case 5:
                    printf("fifteen\n");
                break;
                case 6:
                    printf("sixteen\n");
                break;
                case 7:
                    printf("seventeen\n");
                break;
                case 8:
                    printf("eighteen\n");
                break;
                case 9:
                    printf("nineteen\n");
                break;
                }
        }
    }
        if (y>1&&(x-y*10)!=0){
            printf("-");
        }
        x=x-y*10;
        if (x&&y!=1]){
            switch(x){
                case 1:
                    printf("one\n");
                break;
                case 2:
                    printf("two\n");
                break;
                case 3:
                    printf("three\n");
                break;
                case 4:
                    printf("four\n");
                break;
                case 5:
                    printf("five\n");
                break;
                case 6:
                    printf("six\n");
                break;
                case 7:
                    printf("seven\n");
                break;
                case 8:
                    printf("eight\n");
                break;
                case 9:
                    printf("nine\n");
                break;
            }
        }

    return 0;
}


#include<stdio.h>

int ekok(int y){

    if(y==1){printf("one");}
    if(y==2){printf("two");}
    if(y==3){printf("three");}
    if(y==4){printf("four");}
    if(y==5){printf("five");}
    if(y==6){printf("six");}
    if(y==7){printf("seven");}
    if(y==8){printf("eight");}
    if(y==9){printf("nine");}
    printf("\n");

}
int doshok(int x){

    if(x/10==2){ printf("twenty"); }
    if(x/10==3){ printf("thirty"); }
    if(x/10==4){ printf("forty"); }
    if(x/10==5){ printf("fifty"); }
    if(x/10==6){ printf("sixty"); }
    if(x/10==7){ printf("seventy"); }
    if(x/10==8){ printf("eighty"); }
    if(x/10==9){ printf("ninety"); }

    int l=x-((x/10)*10);
    if(l>=1){
        printf("-");
        ekok(l);

    }
};

int main (){

    int num;
    scanf("%d",&num);
    if(num==ten){printf("ten\n");}
    if(num<10){

        ekok(num);

    }
    if(num>10 && num<20){

        if(num==11){ printf("eleven\n");}
        if(num==12){ printf("twelve\n");}
        if(num==13){ printf("thirteen\n");}
        if(num==14){ printf("fourteen\n");}
        if(num==15){ printf("fifteen\n");}
        if(num==16){ printf("sixteen\n");}
        if(num==17){ printf("seventeen\n");}
        if(num==18){ printf("eighteen\n");}
        if(num==19){ printf("nineteen\n");}

    }

    if(num>=20){

        doshok(num);
    }

    return 0;
}


#include<stdio.h>

int main(){

int n,a,b,q=0;

scanf("%d", &n);

b=n%10;

a=n/10;

if(a == 2)
    printf("twenty");

else if(a == 3)
    printf("thirty");

else if(a == 4)
    printf("forty");

else if(a == 5)
    printf("fifty");

else if(a == 6)
    printf("sixty");

else if(a == 7)
    printf("seventy");

else if(a == 8)
    printf("eighty");

else if(a == 9)
    printf("ninety");

if(b != 0  )8
    if(a!=0)
        if(a!=1)
            printf("-");

if(b == 2 && a!=1)
    printf("two");

else if(b == 3 && a!=1)
    printf("three");

else if(b == 4 && a!=1)
    printf("four");

else if(b == 5 && a!=1)
    printf("five");

else if(b == 6 && a!=1)
    printf("six");

else if(b == 7 && a!=1)
    printf("seven");

else if(b == 8 && a!=1)
    printf("eight");

else if(b == 9 && a!=1)
    printf("nine");

if(n==0)
    printf("zero");

if(n == 10)
    printf("ten");

else if(n == 11)
    printf("eleven");

else if(n == 12)
    printf("twelve");

else if(n == 13)
    printf("thirteen");

else if(n == 14)
    printf("fourteen");

else if(n == 15)
    printf("fifteen");

else if(n == 16)
    printf("sixteen");

else if(n == 17)
    printf("seventeen");

else if(n == 18)
    printf("eighteen");

else if(n == 19)
    printf("nineten");

return 0;
}


#include<stdio.h>

int abd[1000000001];

int main()
{
	long long int a,b,i,cp,max=0,max_ind=0;
	scanf("%lld%lld",&a,&b);
	for(i=a;i<=b;i++)
	{
		for(cp=2;cp <= (i/2)+1;cp++)
		{
			if(i % cp == 0)
				abd[cp] += 1;
			if(abd[cp] > max)
			{
				max_ind = cp;
				max = abd[cp];
			}
		}
	}
	printf("%lld\n",max_ind);
	return 0;
}


#include<stdio.h>

int abd[500000001];

int main()
{
	long long int a,b,i,cp,max=0,max_ind=0;
	scanf("%lld%lld",&a,&b);
	for(i=a;i<=b;i++)
	{
		for(cp=2;cp <= (i/2)+1;cp++)
		{
			if(i % cp == 0)
				abd[cp] += 1;
			if(abd[cp] > max)
			{
				max_ind = cp;
				max = abd[cp];
			}
		}
	}
	printf("%lld\n",max_ind);
	return 0;
}


#include <stdio.h>
int main()
{
    long long int x,y;
    scanf("%d %d",&x,&y);
    if (x==y && x%2!=0) printf("%I64d",x);
    else printf("2");


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r;
    cin>>l>>r;
    if(l==r)
        printf("%d\n",l);
    else
        puts("2");
}


#include <iostream.h>

using namespace std;

int main()
{
    int a,b,h,arr[10]={0},temp,c=0,i=3;
    cin>>a;
    cin>>b;
    h=2;
    cout<<h;}


#include <stdio.h>
#include <string.h>
int main()
{
	int n,m,i,j,a,min1=9,min2=9;
	int a[10]={0},b[10]={0};
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if (a<min1) min1=a;
	}
	for (i=1;i<=m;i++)
	{
		scanf("%d",&a);
		if (a<min2) min2=a;
	}
	for (i=0;i<=9;i++)
		if (a[i]&&b[i])
		{
			printf("%d\n",i); return 0;
		}
	if (min1==min2) printf("%d\n",min1);
	else if (!min1) printf("%d\n",min2*10);
	else if (!min2) printf("%d\n",min1*10);
	else if (min1<min2) printf("%d\n",min1*10+min2);
	else printf("%d\n",min2*10+min1);
	return 0;
}


#include<stdio.h>

int main()
{

    int n,m;

    int min1=10,min2=10,min3=10;
    int k=0;
    scanf("%d %d",&n,&m);

    int a[n+1],b[m+1];
    int keep1[n+1],keep2[m+1];

    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<=min1)
        {
            min1=a[i];
        }

    }

     for(int i=0;i<m;i++)
    {
        scanf("%d",&b[i]);

        if(b[i]<=min2)
        {
            min2=b[i];
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i]==b[j])
            {
                keep1[k]=a[i];

                if(keep1[k]<=min3)
                    min3=keep1[k];

            }

                k++;

        }
    }

     if(min3<10)
    {
        printf("%d\n",min3);
    }

    else if(min1!=min2)
    {
       if(min1<min2)
       {
           printf("%d%d\n",min1,min2);
       }
       else If(min1>min2)
       {
           printf("%d%d\n",min2,min1);
       }

    }

    return 0;

}


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

int main()
{
    int x , y ;
    scanf("%d" ,&x );
    scanf ("%d", &y);
    int line1 [x];
    int line2 [y];
    int i ;
    int great1 = 9;
    int great2 = 9 ;
    int great =0 ;
    for (i=0;i<x;i++){
        scanf("%d", & line1 [i]);
if ( great1 > line1[i] && line1[i]> 0 )
    great1= line1 [i] ;
    }
    for (i=0 ; i<y ; i ++){
        scanf("%d",& line2 [i]);
if ( great2 > line2[i] && line2[i]> 0)
    great2= line2 [i] ;
    }

   if  (great1 > great2 ) {
        great = great2 *10 + great1 ;
   }
   else if  (great2 > great1 ) {
        great = great1 *10 + great2 ;
   }
   else
    great = great1 ;
   int j ;
    for (i =0 ; i < x ; i ++){
        for ( j =0 ; j < y ; j ++){
            if (line1[i]== line2 [j] && line2[j] < great){
                great = line2 [j];8
                break ;}
    }
    }
    printf("%d", great );
    return 0;
}


#include<string.h>
int main()
{
    int arr1[9];

    int arr2[9];
    arr3[];
    arr4[];
    int i;
    int j;

    for(i=0 , i<9 ; i++)
    {

    if(arr1[i]>= '0' && arr1[i]<= '9')
        scanf("%d",&arr1[i]);
    }

    for(j=0 , j<9 ; j++)
    {

    if(arr2[j]>= '0' && arr2[j]<= '9')
        scanf("%d",&arr2[j]);
    }
    if (arr1[i]==arr2[i])
    arr4[]=arr1[i];
    else
    {arr3[]=arr1[i]*10+arr2[i];
    arr4[]=arr2[i]*10+arr1[i];
    }

    if ( arr3[i]< arr4[i])
        for(i=0 ; i<9 ; i++)

if (arr3[i]<arr3[i-1])

        println("The prettiest number:%d",arr3[i]);
    else
        for(i=0 ; i<9 ; i++)

if (arr4[i]<arr4[i-1])
        println("The prettiest number:%d",arr4[i]);
}


#include<stdio.h>
int main()
{
    int no_of_domino;
    scanf("%d",&no_of_domino);
    int arr[no_of_domino][2];
    int upperhalf=0;
    int lowerhalf=0;
    int i;
    int first,second;
    for(i=0;i<no_of_domino;i++)
    {
        scanf("%d%d",&first,&second);
         upperhalf+=first;
         lowerhalf+=second;
    }
    if(upperhalf%2==0&&lowerhalf%2==0)
        printf("%d",0);
    if(upperhalf%2==0&&lowerhalf%2!=0||upperhalf%2!=0&&lowerhalf%2==0)
        printf("-1");
        if(upperhalf%2!=0&&lowerhalf%2!=0&&upperhalf!=1&&lowerhalf!=1)
           printf("1");
           if(uppehalf==1&&lowerhalf==1)
            printf("-1");
           return 0;
}


#include<stdio.h>

int main()
{
    int N,i;
    float resultado;
    scanf("%d",&N);
    for(i=1; i<=N; i++)
    {
        resultado=(float)i/(N-i));
        if(resultado>=1)
        {
            i--;
            break;
        }

    }
    printf("%d %d",i,N-i);
    return 0;

}


#include <iostream>
using namespace std;

void main()
{
    int n;
    cin>>n;
    if(n%4==0)
        cout<<n/2-1<<" "<<n/2+1;
    else if (n%4==2)
        cout<<n/2-2<<" "<<n/2+2;
    else
        cout<<n/2<<" "<<n/2+1;

}


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

(19) - 431C
C. k-Tree
Time limit per test 1 second


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

inline int max(int a, int b) {
    return (a > b)? a: b;
}
inline int abs(int a) {
    return (a > 0)? a: -a;
}

int main(void) {
    char sc, tc;
    int sn, tn;
    scanf("%c%d\n", &sc, &sn);
    scanf("%c%d", &tc, &tn);
    char x[8],y[8],n[8],s[24];
    memset(x,'\0',8);
    memset(x,'R',max(0,tc-sc));
    memset(x,'L',max(0,sc-tc));
    memset(y,'\0',8);
    memset(y,'U',max(0,tn-sn));
    memset(y,'D',max(0,sn-tn));
    int xy = max(abs(sc-tc),abs(sn-tn));
    memset(n,'\0',8);
    memset(n,'\n',xy);
    s[0] = '\0';
    int i;
    for (i = 0; i <= xy; i++) {
        strncat(s,x+i,1);
        strncat(s,y+i,1);
        strncat(s,n+i,1);
    }
    printf("%d\n%s", xy, s);
    return 0;
}


#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
 char start[3] , end[3]  ;
int x , y ;

scanf("%s", &start);
scanf("%s", &end);

x = end[0] - start[0] ;
y = end[1] - start[1]  ;

if (y > x )printf("%d \n" , abs(y));
else printf("%d \n" , abs(x));

while (x !=0 || y!=0 ){
if (x > 0 )
{
	x -= 1 ;
	printf("R");
}
else (x < 0 )
{
	x += 1 ;
	printf("L");

}
if (y > 0 )
{
	y -= 1 ;
	printf("U\n");
}
else (y < 0 )
{
	y += 1 ;
	printf("D\n");

}

}

    return 0;
}


#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

using namespace std;
int main()
{
    char s[5];
    char f[5];

    scanf("%s",s);
    getchar();
    scanf("%s",f);

    int cs=(int)s[0];
    int cf=(int)f[0];

    int rs=(int)s[1];
    int rf=(int)f[1];

    int dc=cf-cs;
    int dr=rf-rs;

    int max=abs(dc)>=abs(dr)?abs(dc):abs(dr);

int diff=abs(dc)-abs(dr);

int moves=abs(diff)+(max-abs(diff));
printf("%d\n",moves);

while( dc!=0 || dr!=0)
{
       if(dc>0)
       {
               printf("L");
               dc--;
       }
       else if(dc<0)
       {
            printf("R");
            dc++;
       }

       if(dr>0)
       {
               printf("U");
               dr--;
       }
       else if(dr<0)
       {
            printf("D");
            dr++;
       }
       printf("\n");

}

   // printf("\n%d%d%d%d",rs,rf,cs,cf);
   // getch();
    return(0);
}


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

void ct1(char a[],char b[])
{
	int i,j;
	i=b[1]-a[1];

	if (i>0)
		{	printf ("%d",i);
			for (j=0;j<i;j++)
				printf ("\nD");
		}
	else if (i<0)
		{
			printf ("%d",-i);
			for (j=0;j>i;j--)
				printf ("\nU");
		}
	else
		printf ("%d",i);
}
int bd(char a)
{
	switch(a)
	{
		case 'A': 	return 1;break;
		case 'B':	return 2;break;
		case 'C':	return 3;break;
		case 'D':	return 4;break;
		case 'E':	return 5;break;
		case 'F':	return 6;break;
		case 'G':	return 7;break;
		case 'H':	return 8;break;
	}
}
void ct2(char a[],char b[])
{
	int m,n,i,j;
	m=bd(a[0]);
	n=bd(b[0]);
	i=n-m;
	if (i>0)
		{
			printf ("%d",i);
			for (j=0;j<i;j++)
				printf ("\nR");
		}
	else if (i<0)
		{
			printf ("%d",-i);
			for (j=0;j>i;j--)
				printf ("\nL");
		}
	else
		{
			printf ("%d",i);
		}
}
void ct3(char a[],char b[])
{
	int m,n,i,j,k,l;
	m=bd(a[0]);
	n=bd(b[0]);
	i=n-m;
	j=b[1]-a[1];
	if ((i>0)&&(j>0))
		{
			if (i>j)
				{
					m+=j;
					a[1]+=j;
					k=n-m;
					printf ("%d",j+k);
					for (l=0;l<k;l++)
						printf ("\nR");
					for (l=0;l<j;l++)
						printf ("\nRU");
				}
			else if (i<j)
				{
					m+=i;
					a[1]+=i;
					k=b[1]-a[1];
					printf ("%d",i+k);
					for (l=0;l<k;l++)
						printf ("\nR");
					for (l=0;l<i;l++)
						printf ("\nRU");

				}
			else
				{
					printf ("%d",i);
					for (l=0;l<i;l++)
						printf ("\nRU");
				}
		}
	else if ((i>0)&&(j<0))
		{
			if (i>-j)
				{
					m-=j;
					a[1]-=j;
					k=n-m;
					printf ("%d",-j-k);
					for (l=0;l<(-k);l++)
						printf ("\nR");
					for (l=0;l<-j;l++)
						printf ("\nRD");
				}
			else if (i<-j)
				{
					m+=i;
					a[1]+=i;
					k=b[1]-a[1];
					printf ("%d",i-k);
					for (l=0;l<-k;l++)
						printf ("\nR");
					for (l=0;l<i;l++)
						printf ("\nRD");

				}
			else
				{
					printf ("%d",i);
					for (l=0;l<i;l++)
						printf ("\nRD");
				}
		}
	else if ((i<0)&&(j>0))
		{
			if (-i>j)
				{
					m+=j;
					a[1]+=j;
					k=n-m;
					printf ("%d",j-k);
					for (l=0;l<-k;l++)
						printf ("\nL");
					for (l=0;l<j;l++)
						printf ("\nLU");
				}
			else if (-i<j)
				{
					m-=i;
					a[1]-=i;
					k=b[1]-a[1];
					printf ("%d",-i+k);
					for (l=0;l<k;l++)
						printf ("\nL");
					for (l=0;l<-i;l++)
						printf ("\nLU");

				}
			else
				{
					printf ("%d",-i);
					for (l=0;l<-i;l++)
						printf ("\nLU");
				}
		}
	else
		{
			if (j>i)
				{
					m-=j;
					a[1]-=j;
					k=n-m;
					printf ("%d",-j-k);
					for (l=0;l<-k;l++)
						printf ("\nL");
					for (l=0;l<-j;l++)
						printf ("\nLD");
				}
			else if (j<i)
				{
					m-=i;
					a[1]-=i;
					k=b[1]-a[1];
					printf ("%d",-i-k);
					for (l=0;l<-k;l++)
						printf ("\nL");
					for (l=0;l<-i;l++)
						printf ("\nLD");

				}
			else
				{
					printf ("%d",-i);
					for (l=0;l<-i;l++)
						printf ("\nLD");
				}
		}
}
int main()
{	char a[2],b[2];
	scanf ("%s",a);
	scanf ("%s",b);
	if (a[0]==b[0])
		ct1(a,b);
	else if (a[1]==b[1])
		ct2(a,b);
	else
		ct3(a,b);
	RETURN 0;
}


#include<stdio.h>
int main(){
    long long int n,x,t=0;
    scanf("%llu",&n);
    for(i=1;i<=n;i=i*10)
    {
        t=n-i+1;
    }
    printf("%llu",t);

}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
 int x,n;
  long long int T=0;
    scanf("%d",&n);
   for(x=1;n>=x;x*=10)
   {
    T+=n-x+1;
   }
cout<<T;
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int n,i;
    int count=-1;
    int temp=9;
    int sum=0;
    long long result;
    scanf("%d",&n);
    i=n;
    while(i>0)
    {
        i=i/10;
        count++;
    }
    if(count >0)
    {
        //sum = ((n+1.0) - pow(10.0,(double)count));
        sum = ((n+1) - power(10,count));
        sum = sum*(count+1);
    }
    else
    {
        sum = n;
     }
     i=1;
    while(i<=count)
    {
        sum += temp * power(10,(i-1)) *i;
        i++;
    }
    result = (long long)sum;
    printf("I64d",result);
    return 0;
}
int power(int a, int b)
{
    int i=0,exp=1;
    for(i=1;i<=b;i++)
    {
        exp *= a
    }
    return exp;
}


#include <stdio.h>
#include <iostream>
using namespace std;

int time10(int x);

int main(void){

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

    int n, tmp;
    tmp = input;
    for(n=0; tmp/10 > 0; n++){
        tmp /= 10;
    }

    unsigned long long int ans;
    ans = (input-time10(n)+1)*(n+1);

    int i;
    for(i=1; i<=n; i++){
        ans = ans + 9*time10(i-1)*(i);
    }

    cout << ans << endl;

    return 0;
}

int time10(int x){
    int i, out = 1;
    for(i=0; i<x; i++){
        out *= 10;
    }
    return out;
}


#include<stdio.h>
#include<math.h>
int main()
{
      int day;
      char s1[15];
      scanf("%d",&day);
      scanf("%s",s1);
      scanf("%s",s1);
      if(s[0]=='w')
      {
            if(day==5||day==6)
            printf("53\n");
            else
            printf("52\n");
      }
      else
      {
            if(day<=29)
            printf("12\n");
            else if(day<=30)
            printf("11\n");
            else
            printf("7\n");
      }
}


#include <stdio.h>

int main(void) {
    int x;
    char a[10],b[10];
    scanf("%d%s%s",&x,b,a);
    if(strcmp(a,"week")==0)
    {
        if(x==5 || x==6)
        printf("53");
        else
        printf("52");
    }
    else
    {
        if(x<=29)
        printf("12");
        else if(x==30)
        printf("11");
        else
        printf("7")
    }
    return 0;
}


#include <stdio.h>
#define SIZE 300

int main()
{
	int x;
	char s[SIZE];

	scanf_s("%d of ", &x);
	gets_s(s, 300);

	if (s[0] == 'w') {
		if (x >= 4 && x <= 6)
			printf("52");
		else
			printf("51");
	} else {
		if (x == 31)
			printf("7");
		else if (x == 30)
			printf("11");
		else
			printf("12");
	}

	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int d,m;
    char w[10];
    printf("input\n");
    scanf("%d",&d);
    getchar();
    gets(w);
    if(strcmp(w,"of week"))
    {
      m=d;
    printf("output\n");
    if(m==31)
    {
        printf("7");
    }
    else if(m==30)
    {
        printf("11");
    }
    else if(m>=1 && m<30)
    {
        printf("12");
    }
    else
    {
        printf("")
    }
    }
    else
    {
     printf("output\n");
    if(d==1 || d==2 || d==3 || d==4 || d==7)
    {
        printf("52\n");
    }
    else if(d==5 || d==6)
    {
        printf("53\n");
    }
    }
    return 0;
}


/* DHUOJ solution #360677 @ 2018-08-08 11:49:50.318 */

#include <iostream>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	int n;
	int a[105] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int tem = 0, ans = 0;
	bool flag = 1;
	for (int i = 0; i < n && flag; i++) {
		if (a[i] != a[0] && a[i] != tem) {
			if (tem) flag = 0;
			else {
				tem = a[i];
			}
		}
		else if (a[i] == a[0]) ans++;
	}
	if (flag && ans * 2 == n) {
		cout << "YES" << endl;
		cout << a[0] << ' ' << tem << endl;
	}
	else cout << "NO" << endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[102]={0};
    int b[4];
    int num;
    int index=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num);
        a[num]++;
    }
    int flag=0;
    for(int i=1;i<=100;i++)
    {
        if(a[i]>0&&a[i]!=n/2)
        {
            printf("NO\n");
            flag=1;
            break;
        }
        if(a[i]==n/2)
        {
            index++;
            b[index]=i;
        }
    }
    if(!flag)
    {
        printf("YES\n%d %d\n",b[1],b[2]);
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
const int maxn = 111;
int num[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int flag=1;
    int k1=0,k2=0;
    int a;
    for(int i=1;i<=n;i++){
        scanf("%d",&a);
        if(!flag) continue;
        if(num[a]==0){
            num[a]++;
            if(!k1){
                k1=a;
                continue;
            }
            if(!k2){
                k2=a;
                continue;
            }
            if(k1!=0&&k2!=0){
                flag=0;
            }
        }
        num[a]++;
    }
    if(flag&&num[k1]==num[k2]){
        printf("YES\n%d %d\n",k1,k2);
    }
    else
        printf("NO\n");
    return 0;
}


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

int main(){
	int t, i, n, s = 1, a = 0, b = 0;
	scanf("%d", &n);
	scanf("%d", &a);
	for (i = 1, i < n, ++i){
		scanf("%d", &t);
		if (t != a){
			if (b == 0){
				b = t;
			}
			else if (b != t){
				printf("NO");
				return 0;
			}
		}
		else s++;
	}
	if (s * 2 != n || b == 0){
		printf("NO");
		return 0;
	}
	else {
		printf("YES\n%d %d", &a, &b);
	}

	return 0;
}


#include<iostream>
#include<string>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
ll a, b, f, k;
int main()
{
    while (cin >> a>>b>>f>>k)
    {
        int cnt = 0;
        if (b < f||b<a-f)  //k==1
        {
            cout << "-1" << endl;
            continue;
        }
        if (k == 1)
        {
            b -= f;
            if (b < (a - f))
                cnt++;
            cout << cnt << endl;
            continue;
        }
        if (b < 2 * (a - f)) //k==2;
        {
            cout << "-1" << endl;
            continue;
        }int c = b,i;
        if (k == 2)
        {
            b -= f;
            if(b<2*(a-f))
            {
                b = c;
                cnt++;
            }
            b -= 2 * (a - f);
            if (b < f)
            {
                cnt++;
            }
            cout << cnt << endl;
            continue;
        }
        if (b < 2 * f)
        {
            cout << "-1" << endl;
            continue;
        }

        b -= f;
        for(i=1;i<k-1;i+=2)
        {
                if (b < 2 * (a - f))
                {
                    b = c;
                    cnt++;
                }
                b -= 2 * (a - f);
                if (b < 2 * f)
                {
                    b = c;
                    cnt++;
                }
                b -= 2 * f;
        }
        if (i==k)
        {
            if (b < a-f)
                cnt++;
            cout << cnt << endl;
        }
        else
        {
            if (b < 2 * (a - f))
            {
                b = c;
                cnt++;
            }
            b -= 2 * (a - f);
            if (b < f)
            {
                b = c; cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


//http://codeforces.com/contest/731/problem/A
#include<stdio.h>
int strlen(char *ptr);
int abs(int number);
int main(void)
{
char start,pointer;
int steps=0, i=0, temp, len1, number1;
char arr[101];
scanf("%s", arr);
start='a';
len1=strlen(arr);
pointer=arr[0];
while(i<len)
{
temp=pointer-start;
temp = abs(temp);
if(temp<=13)
{
number1=pointer-start;
steps+=abs(number1);
}
else
{
if(pointer>=start)
{
number1=25-pointer+1+start;
steps+=abs(number1);
}
else
{
number1=25+pointer+1-start;
steps+=abs(number1);
}

}
start=arr[i+1];
pointer=arr[i];
i++;
}
printf("%d\n", steps);

return 0;
}

int abs(int number)
{
if(number>=0);
else
number*=-1;
return number;

}

int strlen(char *ptr)
{
int i=0;
while(ptr[i]!='\0')
{
i++;
}
return i;
}


#include<stdio.h>
int main()
{
char s[100];
int c,d
gets(s);
int x=strlen(s);
int i;
char ch='a';
int sum=0;
for(i=0;i<x;i++)
{
int y=ch-s[i];
if(y<0)
{
y=-y;
}
c=26;
d=y;
if(c<d)
{
sum=c;
}
else
{
sum=sum+d;
}
ch=s[i];
}
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="lettre_wheel" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/lettre_wheel" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/lettre_wheel" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include<stdio.h>
#include<math.h>
int min(int a,int b){
       if(a<b)       return a;
       else return b;
}
int main(){
       char s[102];
       s[100]='A';
       gets(s);
       while(s!='\0'){
              a += abs(s[100]-i);
              sum += min(a,26-a);
              s[100]=s[i];
              s++;
       }
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
  chaine c="";
  char a;
  int i=0,k=0,d=0;
  while((strlen(c)==0)||(strlen(c)>100)||(k==0))
  {   i=0;
      k=1;
      printf("donner le mot a saisir ");
      scanf("%s",&c);
      while(i<=strlen(c)-1)
      {if((c[i]<'a')||(c[i]>'z'))
         k=0;
         i++;}
  }
  a='a';
  i=0;
  while(i<strlen(c))
  {
      k=fabs(a-c[i]);
      if(k>13)
        k=26-k;
      d=d+k;
      a=c[i];
      i++;

  }
  printf("%d",d);
}


#include <stdio.h>
main()
{
    int n,k,i,r,ck;
    float add,avg,check;

   while(2== scanf("%d%d",&n,&k)){
    int a[n];
    add=0;
    for(i=0;i<n;i++)
       {scanf("%d",&a[i]);
         add=add+a[i];
       }
       check=add/n;
       check=check+.5;
       ck=(int) check;
       if(ck==n)
        printf("%d\n",0);
       else
       {

    for(i=n+1; ;i++)
       {
           add=add+k;

           avg=(add*1.0/i);
           avg=avg+.5;
           r=(int) avg;
           if(r==k) break;
       }
       printf("%d\n",i-n);
   }
}


#include <stdio.h>

int main(void)
{
    int n,k;
    int i=0;
    int *a;
    int sum=0;

    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum += (k-a[i]);
    }

    sum = 2*sum - n;
    x= sum-1;

    printf("%d",x);

    return 0;

}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){int n,i;
  int k,s=0,d;
    scanf("%d %d\n",&n,&k);
int a[n];
    for (i=0;i<n;i++)
    {scanf("%d ",&a[i]);
    s=s+a[i];
    }

 for (i=0;i<1000000;i++)
    { if(i>0)s=s+k;
     if(s*2>=(((n+i)*(2k)-(n+i)))){printf("%d",i); return 0;}
    }
    return 0;
}


#include <stdio.h>

int main(void)
{
    int n,k;
    int i=0,ans=0;
    int a;
    int sum=0;

    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        sum += (a-k);
    }
    sum/n<=-1/2
    if( (sum >= 0) || (2*sum) <= (-1)*n) printf("0\n");
    else
    {
        ans = -2*sum-n;
    }

    printf("%d",ans);

    return 0;
}


#include<stdio.h>
int main(void)
{
    int n,k,i,sum=0,a[120],sm;
    float s,div;
    scanf("%d %d",&n,&k);
    for(i=1;i<=n;i++)
    {
      scanf("%d",&a[i]);
      sum=sum+a[i];
    }
    i--;
    s=float(sum);
    sm=sum;
    sum=sum/i;
    s=s/float(i);
    s=s-float(sum);
    if(s==0||s<0.5)
    s=float(sum);
    else
    s=float(sum)+1;
    if(s<float(k-0.5))
    {
     s=float(sm);
     while(1)
     {
       s=s+float(k);
       div=s/float(i+1);
       i++;
       if(div>=float(k-0.5))
        break;
     }
     printf("%d",i-n);
    }
    else
    printf("%d",i-n);
    return 0;
}


include<stdio.h>
int main()
{
    names[4] = { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };
    long n;
    scanf("%d",&n);
    long T[n];
    for(int i = 0 ; i<n; i++)
    {
        for(int j = i; j<=i*i;i++)
        {
            T[n]=names[i%4];
        }
    }
    printf("%d",T[n]);
    return 0;
}


#include <stdio.h>
int a[1000000000];
int main (){
    int i,x,n,y=5,z=6;
    a[0]=1;
    a[1]=2;
    a[2]=3;
    a[3]=4;
    a[4]=5;
    scanf("%d",&n);
    for(i=0;i<n-1;i++){
    a[y]=a[i];
    a[z]=a[i];
    y+=2;
    z+=2;
    }
    x=a[n-1];
    switch (x){
        case 1 :
        printf("Sheldon");
        break;
        case 2 :
        printf("Leonard");
        break;
        case 3 :
        printf("Penny");
        break;
        case 4 :
        printf("Rajesh");
        break;
        case 5 :
        printf("Howard");
        break;
    }

return 0 ;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n;
    scanf("%d",&n);
    int a = 1;
      while(a*5<n){
          n -= a*5;
          a *=5;
      }
      n = n-1;
      n = n/a;
      if(n == 0){
          printf("Sheldon\n");
      }
      else if (n == 1){
          printf("Leonard\n";
          }
          else if(n == 2){
              printf("Penny\n");
          }
          else if (n == 3){
              printf("Rajesh\n");
          }
          else {
              printf("Howard\n");
          }
}


#include <stdio.h>
#include <math.h>
int main(){
 int i;
 double n;
 char *name[5]={"Sheldon","Leonard","Penny","Rajesh","Howard"};
 i=ceil(log(n/5+1)/log(2));
 n=ceil(n-5*(1<<(i-1)-1)/1<<(i-1))
 printf("%s", name[n-1]);
 return 0;
 }


#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
  int n,f,d=0,a[6],b[6],c=5,i,e=0,g=5;
  scanf("%d",&n);

  for(i=1;i<=5;i++)
  {
    a[i]=i;
  }
  while(c<=n)
  {
    e=c;
    g=g*2;
    c=c+g;
    d++;
  }

  if(d==0)
  {
     if(n==1)
    printf("Sheldon");
    if(n==2)
    printf("Leonard");
    if(n==3)
    printf("Penny");
    if(n==4)
    printf("Rajesh");
    if(n==5)
    printf("Howard");
  }
  else
  {
  for(i=1;i<=5;i++)
  {
    a[i]=a[i]*pow(2,d);
    b[i]=a[i];
    b[i]=b[i]+e;

    printf("%d
  }
  for(i=1;i<=5;i++)
  {
    if(n<=b[i])
    {
    if(i==1)
    printf("Sheldon");
    if(i==2)
    printf("Leonard");
    if(i==3)
    printf("Penny");
    if(i==4)
    printf("Rajesh");
    if(i==5)
    printf("Howard");
    break;
    }

  }
  }
  return(0);

}


#include<stdio.h>
main()
int i,e=0;
{
    char a,b,c,d;
    scanf("%c%c",&a,&b);
    for(i=0;i<5;i++)
    {
        scanf("%c%c",&c,&d);
        if(a==c||a==d) e=e+1;
        if(b==c||b==d) e=e+1;
    }
    if(e!=0) {printf("yes");}
    else {printf("no");}

}


 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct liste{
    char name[30];
    struct liste *next;
};
typedef struct liste *liste ;
liste creation(int n){
    liste head,tmp,pt;
         head=malloc(sizeof(struct liste));
         scanf("%s",head->name);
        if(strlen(head->name)!=2)exit(EXIT_FAILURE);
            head->next=NULL;
            pt=head;
     for(int i=1;i<n;i++){
           tmp=malloc(sizeof(struct liste));
           scanf("%s",tmp->name);
           if(strlen(head->name)!=2)exit(EXIT_FAILURE);
           tmp->next=NULL;
           pt->next=tmp;
           pt=tmp;
     }
      return head;

}
int traitement(char card[],liste L){
    int i=0;

liste p;

    do{
        p=L;
             while(p){
                if(card[i]==p->name[i])){
                 printf("YES");
                return 0;
                                }
                                p=p->next;
             }
             i++;

    }while(i<2);

    printf("NO");
}
 int main(){
char card[2];
liste L;
 scanf("%s",card);
 if(strlen(card)!=2)return 0;
 L=creation(5);
   traitement(card,L);

}


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

int main()
{
    char name[3], test[3], ans[] = "23456789TJQKA";
    int i, j, a, length, count = 0,b;

    length = strlen(ans);

    scanf("%s", name);

    for(i=1; i<=5; i++)
    {
        scanf("%s", test);

        if( (test[0] == 'A' && name[0] == 'A'){

            count = 1;
        }
        else if((test[0] == name[0]) && (test[1] == name[1])){

            count = 1;
        }
        else if(test[1] == name[1]){

            for(j=0; j<length; j++){

                if( (name[0] == ans[j])){

                    a = (j+1);
                }
                if(test[0] == ans[j]){

                    b = (j+1);
                }
            }

            if(b>=a){

                count = 1;
            }
        }
    }

    if(count == 1){

        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
	<FileVersion major="1" minor="0" />
	<ActiveTarget name="Debug" />
	<File name="main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
		<Cursor>
			<Cursor1 position="324" topLine="0" />
		</Cursor>
	</File>
</CodeBlocks_layout_file>