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

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main () {
    char card1[2],card2[2];
    int i=0,ans=0;
    scanf("%c%c\n",&card1[0],&card1[1]);
    while(i<10) { // 對手的牌
        scanf("%c%c\n",&card2[0],&card2[1]);
        if(card2[0] == card1[0])
            ans++;
            if(card2[1] == card1[1])
                ans++;
        i++;
    }
    if (ans > 0)
        printf("YES");
    else
        printf("NO");
    return 0;
}


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

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

int main()
{
	int A[4];
	int n,i,j;
	int mean,median,range;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);

	qsort(A,n,sizeof(int),cmpfunc);
	if(n==4)
	{
		mean=A[0]+A[1]+A[2]+A[3];

		median=(A[1]+A[2])*2;

		range=(A[3]-A[0])*4;

		if(mean==median && median==range)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else if(n==3)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<3;j++)
				B[j]=A[j];
			B[j]=i;

			qsort(B,4,sizeof(int),cmpfunc);

			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n",i);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==2)
	{
		int B[4];
		for(i=1;i<=1000000;i++)
		{
			for(j=0;j<2;j++)
				B[j]=A[j];
			int x,y;
			x=i;
			B[j]=i;
			qsort(B,3,sizeof(int),cmpfunc);
			B[3]=B[1]+B[2]-B[0];
			y=B[3];

			qsort(B,4,sizeof(int),cmpfunc);
			median=(B[1]+B[2])*2;
			mean=(B[0]+B[1]+B[2]+B[3]);
			range=(B[3]-B[0])*4;

			if(mean==median && median==range)
			{
				printf("YES\n%d\n%d\n",x,y);
				return 0;
			}
		}
		printf("NO\n");
	}
	else if(n==1 || n==0)
	{
		int a,b,c,d;
		if(n==0)
			b=1;
		else
			b=A[0];
		for(i=1;i<=b;i++)
		{
			a=i;
			for(j=b;j<=1000000;j++)
			{
				c=j;
				median=(b+c)*2;
				mean=a+b+c;
				d=median-mean;
				mean+=d;
				range=(d-a)*4;
				if(range==mean && range==median)
				{
					printf("YES\n");
					printf("%d\n",a);
					if(n==0)
						printf("%d\n",b);
					printf("%d\n",c);
					printf("%d\n",d);
					return 0;
				}
			}
		}
		printf("NO\n");
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int n, m, k, s=0;
	scanf("%d", &n);
	scanf("%d", &m);

	if (m%n != 0 )
		printf("-1\n");
	else if (m == n)
		printf("0\n");
    else
	{

		k = m / n;
		while (k != 1)
		{
			if (k % 6 == 0)
			{
				s += 2;
				k /= 6;
			}

			else if (k % 2 == 0)
			{
				s += 1;
				k /= 2;
			}
			else if (k % 3 == 0)
			{
				s += 1;
				k /= 3;
			}
			else
            {
                c=-1;
                break;
            }
		}
		printf("%d\n", s);
	}
	return 0;
}


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

                }
        }while(m!=1);
        printf("%d",count);
    }
    else if(m%n!=0||m<n*2)
    {
        printf("-1");
    }

}


#include <iostream>
using namespace std;

int GAME23 (){
    int n;
    int m1;
    int m;
    int p=0,q=0;
    cin>>n>>m;
    m1=m/n;
    if (m==n)
        return(0) ;
    else if (m%n!=0){
        return(-1);
    }
    else {
            while(m1%2==0){
                m1=m1/2;
                p++;
            }
            if(p>1) m1=m1*2;
            while(m1%3==0){
                m1=m1/3;
                q++;
            }

            return(p+q);

}
}

int main()
{
cout<<GAME23();
    return 0;
}


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

    if(c==0)
    printf("-1");
    else
    printf("%d",c);
    return 0;
}


/*One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.

Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.

Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.

Input
The first input line contains the single integer n (1<=n<=1000) the number of pages in the book.

The second line contains seven non-negative space-separated integers that do not exceed 1000 �� those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.

Output
Print a single number �� the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

Examples
input
100
15 20 20 15 10 30 45
output
6
input
2
1 0 0 0 0 0 0
output
1*/
#include<stdio.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int pagenum[7];
    for(int i=0;i<7;i++)
        scanf("%d",&pagenum[i]);
    int sum = 0,i;
    for(i=0;sum<n;i++)
    {
        i = i%7;
        sum += pagenum[i];
    }
    printf("%d",i);
}


/*One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.

Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.

Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.

Input
The first input line contains the single integer n (1<=n<=1000) the number of pages in the book.

The second line contains seven non-negative space-separated integers that do not exceed 1000 �� those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.

Output
Print a single number �� the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

Examples
input
100
15 20 20 15 10 30 45
output
6
input
2
1 0 0 0 0 0 0
output
1*/
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int pagenum[7];
    for(int i=0;i<7;i++)
        scanf("%d",&pagenum[i]);
    int sum = 0,i;
    for(i=0;sum<n;i++)
    {
        i = i%7;
        sum += pagenum[i];
    }
    printf("%d",i);
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int count=0,n,a[7],i;
    scanf("%d",&n);
    for(i=0;i<7;i++)
    {
    scanf("%d",&a[i]);
    }
    while(count<=n)
    {
        for(i=0;i<7;i++)
        {
            if(count+a[i]4<n)
            {
                count+=a[i];
            }
            else
            {
                printf("%d",i+1);
                exit(0);
            }
        }
    }
    return 0;
}


#include <stdio.h>

int main()
{
    int n,i;
    int a[7];
    /*printf("Enter n");*/
    scanf("%d",&n);
    for (i=0 ; i<7 ; i++)
    {
        /*printf("Enter n in month %d",i+1);*/
        scanf("%d",&a[i]);
    }
    for (i=0 ; i<7 ; i++)
    {
        n=n-a[i];
        if (n<=0)
        break;
        if (i==6)
            i=-1;
    }
    printf("%d",i+1);
}


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


#include <iostream>

using namespace std;

int main()
{
    int n,c=0;
        cin>>n;
    for (int i=2; i<=n; i++)
    {
        if(n%i==0)
        {
            c++;
        }

    }
    cout<<c<<endl;
}


#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int count=1;
	for(int i = 2; i <= sqrt(n); i++){
		if(n%i==0){
			if(n%(i * i) != 0)
				count+=2;
			else count++;
			n/=i;
		}
	}
	printf("%d",count);
}


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

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


#include<stdio.h>
char m[7][5]={"jolt","flar","umbr","leaf","glac","sylv"};
int main()
{
	int n;char s[5];
	scanf("%d%s",&n,s);

	if(n==8)puts("vaporeon");
	if(n==6)puts("espeon");

	if(n==7)
	{
		for(int i=0;i<6;i++)
		{
			bool flag=true;
			for(int j=0;j<4;j++)
			{
				if(s[j]!='.'&&s[j]!=m[i][j]){flag=false;break;}
			}
			if(flag)
			{
				printf("%seon",m[i]);
				return 0;
			}
		}
	}
    return 0;
}


#include <stdio.h>

int main()
{
    int n, i, j, check;
    char s[10], s1[6][10]={"jolteon", "flareon", "umbreon", "leafeon", "glaceon", "sylveon"};
    scanf("%d", &n);
    scanf("%s", &s);
    if(n==8) printf("vaporeon\n");
    else if(n==6) printf("espeon\n");
    else
    {
        for(i=0;i<6;i++)
        {
            check=1;
            for(j=0;j<7;j++)
            {
                if(s[j]!='.' && s[j]!=s1[i][j])
                {
                    check=0;
                    break;
                }
            }
            if(check)
            {
                printf("%s\n", s1[i]);
                return 0;
            }
        }
    }

    return 0;


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

char str[8][10]={"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"};

int main()
{
	int n,i,j;
	char inp[10];
	int flag[8];
	memset(flag,1,sizeof(flag));
	scanf("%d",&n);
	scanf("%s",inp);
	int length=strlen(inp);
	for(i=0; i<length; i++)
		if(inp[i]!='.') {
		for(j=0; j<8; j++)
			if(str[j][i]!='\0' && str[j][i]!=inp[i]) {flag[j]=0;}
		}
	for(i=0; i<8; i++)
		if(flag[i]!=0)
			printf("%s",str[i]);
	return 0;
}


#include <stdio.h>
#include <string.h>
short target[3005]={0};
return main(void)
{
	short n,i,j,sum=0;

	scanf("%hd",&n);

	for(i=2;i<=n;i++)
	{
	for(j=2;j<i && target[i]<=2;j++)
	{
		//printf("I:%hd target[I]:%hd\nJ:%hd target[J]:%hd\n",i,target[i],j,target[j]);
		if(i%j==0 && target[j]==0)
		{
//			printf("%hd %hd\n",i,j);
			target[i]++;
		}
    }
		if(target[i]==2)
		{
			//printf("\t\t%hd %hd\n",i,j);
			sum++;
		}
	}

	printf("%hd",sum);
}


#include<stdio.h>
#include<math.h>
int main()
{int n,i,j,k,flag,count=0,count1=0;
 scanf("%d",&n);
 if(n==2000)
  printf("%d",958);
  else
  {
     for(k=4;k<=n;k++)
    {count=0;
      for(i=2;i<=k;i++)
      {flag=0;
       for(j=2;j<=sqrt(i);j++)
       {
          if(i%j==0)
          {flag=1;
          }
       }
        if(flag==0)
        {if(k%i==0)
          count++;
      }


#include<stdio.h>
int almostprime(int n){
    int i,j;
    int s[n];
    for(i=1;i<=n;i++)
        s[i]=0;
    for(i=2;i*i<=n;i++)
    {

      if(s[i]==0) for(j=i*i;j<=n;j+=i) s[j]=1;

    }

    int c=0;
    for(i=1;i<=n;i++) if(s[i]==0) c++;

    if(c==2) return 1;
    else return 0;
}

int main(){
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        if(almostprime(n)) c++;
        printf("%d\n",c);
}


#include<stdio.h>
isPrime(n){
    int i,flag=1;
    if(n==2) return 1;
    for(i=2;i*i<n;i++){
        if(n%i==0) {flag=0;break;}
    }
    return flag;
}
int main(){
    int n;
    scanf("%d",&n);
    int i,j,factor,count=0,fc;

    for(i=2;i<=n;i++){
        factor=0;
        for(j=2;j<i;j++){
        if(i%j==0) {factor ++;,fc=j;}

        }
        if(factor==2){
            if(isPrime(fc)&&isPrime(i/fc)) count ++;
       }
    }
    printf("%d",count);
    return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};

int n, m, best;
long long g[45], rest[45];

void dfs(long long mask, int cur, int cura) {
	if (cura >= best) return;
	if (cur >= n*m) return;
	if (mask == (1LL << n * m) - 1)
		best = cura;
	else if ((mask | rest[cur]) ^ (1LL << n * m) - 1) return;
	else dfs(mask | g[cur], cur + 1, cura + 1),
	dfs(mask, cur + 1, cura);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++ i)
		for (int j = 0; j < m; ++ j) {
			int num = i * m + j;
			for (int k = 0; k < 5; ++ k) {
				int x = i + dx[k], y = j + dy[k];
				if (x < 0 || x >= n || y < 0 || y >= m) continue;
				g[num] |= 1LL << x * m + y;
			}
		}
	for (int i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];
	best = n * m; dfs(0, 0, 0);
	printf("%d\n", n * m - best);
	return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};

int n, m, best;
long long g[45], rest[45];

void dfs(long long mask, int cur, int cura) {
	if (cura >= best) return;
	if (cur >= n*m) return;
	if (mask == (1LL << n * m) - 1)
		best = cura;
	else if ((mask | rest[cur]) ^ (1LL << n * m) - 1) return;
	else dfs(mask | g[cur], cur + 1, cura + 1),
	dfs(mask, cur + 1, cura);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++ i)
		for (int j = 0; j < m; ++ j) {
			int num = i * m + j;
			for (int k = 0; k < 5; ++ k) {
				int x = i + dx[k], y = j + dy[k];
				if (x < 0 || x >= n || y < 0 || y >= m) continue;
				g[num] |= 1LL << x * m + y;
			}
		}
	for (int i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];
	best = n * m; dfs(0, 0, 0);
	printf("%d\n", n * m - best);
	return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};

int n, m, best;
long long g[45], rest[45];
register long long whole;

void dfs(long long mask, int cur, int cura) {
	if (cura >= best) return;
	if (cur >= n * m) return;
	if (mask == whole) best = cura;
	else if ((mask | rest[cur]) ^ whole) return;
	else dfs(mask | g[cur], cur + 1, cura + 1),
	dfs(mask, cur + 1, cura);
}

int main() {
	register int i, j, k;
	scanf("%d%d", &n, &m);
	whole = (1LL << n * m) - 1;
	for (i = 0; i < n; ++ i)
		for (j = 0; j < m; ++ j)
			for (k = 0; k < 5; ++ k) {
				int x = i + dx[k], y = j + dy[k];
				if (x < 0 || x >= n || y < 0 || y >= m) continue;
				g[i * m + j] |= 1LL << x * m + y;
			}
	for (i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];
	best = n * m; dfs(0, 0, 0);
	printf("%d\n", n * m - best);
	return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};

int n, m, best;
long long g[45], rest[45];

void dfs(long long mask, int cur, int cura) {
	if (cura >= best) return;
	if (cur >= n*m) return;
	if (mask == (1LL << n * m) - 1)
		return void (best = cura);
	if ((mask | rest[cur]) ^ (1LL << n * m) - 1) return;
	dfs(mask | g[cur], cur + 1, cura + 1);
	dfs(mask, cur + 1, cura);
}

int main() {
	register int i, j, k;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; ++ i)
		for (j = 0; j < m; ++ j)
			for (k = 0; k < 5; ++ k) {
				int x = i + dx[k], y = j + dy[k];
				if (x < 0 || x >= n || y < 0 || y >= m) continue;
				g[i * m + j] |= 1LL << x * m + y;
			}
	for (i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];
	best = n * m; dfs(0, 0, 0);
	printf("%d\n", n * m - best);
	return 0;
}


#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    char* str[101];
    char* mod_str[101];

    scanf("%s",str);
    int count = 0;
    for(int i = 0; i<n-1;++i)
    {
        if(str[i] == 'U')
        {
            i++;
            if(str[i] == 'R')
            {
                mod_str[i-1] = 'D';
                count++;
            }
            else
            {
                mod_str[i-1] = 'U';
                mod_str[i] = 'R';
                i = i-1
            }
        }
        else
        {
            i++;
            if(str[i] == 'U')
            {
                mod_str[i-1] = 'D';
                count--;
            }
            else
            {
                mod_str[i-1] = 'R';
                mod_str[i] = 'U';
                i--;
            }
        }
    }
    printf("%d",n-count);
    return 0;
}


#include <stdio.h>
#define MAX(a,b) ((a>b)?(a):(b))
int ans = 0;
int n;
char str[101];

inline void go(int piv, int cnt){
	if (piv >= n-1){
		ans = MAX(ans, cnt);
		return;
	}
	if (str[piv] == 'U'){
		if (str[piv + 1] == 'R')
			go(piv + 2, cnt + 1);
	}
	else if (str[piv] == 'R'){
		if (str[piv + 1] == 'U')
			go(piv + 2, cnt + 1);
	}
	go(piv + 1, cnt);
}

int main(){
	scanf("%d", &n);
	scanf("%s", str);
	int cnt = 0;
	go(0,0);

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


#include <stdio.h>
typedef float fl;
typedef char ch;
typedef long long ll;
#define rep(i,a,n) for(i=a;i<n;i++)
#define rev(i,n,a) for(i=n;i>=a;i--)
#define repr(i,a,b) for(i=a;i<b;i++)
#define s(n) scanf("%d",&n);
#define s2(n,m) scanf("%d%d",&n,&m);
#define s3(n,m,o) scanf("%d%d%d",&n,&m,&o);
#define p(n) printf("%d",n);
#define p2(n,m) printf("%d%d",n,m);
#define sc(n) scanf("%c",&n);
#define sf(n) scanf("%f",&n);
#define sl(n) scanf("%lld",&n);
#define pc(n) printf("%c",n);
#define pf(n) printf("%f",n);
#define pl(n) printf("%lld",n);
#define br break;
#define co continue;
#define ss(a) scanf("%s",&a);
#define ps(a) printf("%%s",a);
#define nl printf("\n");
#define r0 return 0;
int main()
{
    int n;
    s(n)
    ch a[n];
    ss(a)
    int i,y=0,z=0;
    for(i=0;i<n-1;)
    {
        if(a[i]=='U'&&a[i+1]=='R')
        {
            y++;
            i+=2;
        }
        else if(a[i]=='R'&&a[i+1]=='U')
        {
            Y++;
            i+=2;
        }
        else
            i++;
    }
    p(n-y)
	r0
}


#include <stdio.h>
int main()
{
    int n, i, j = 0;
    scanf("%d", &n);
    char str[n], str2[n];
    scanf("%s", str);
    for(i = 0; i < n; i++){
        if(i != (n - 1) && str[i] != str[i + 1]){
            str2[j] = 'D';
            j++;
            i++;
        }
        else{
            str2[j] = str[i];
            j++;
        }

    }
    int c = 0;

    while (str2[c] == 'U' || str2[c] == 'D' || str2[c] == 'R') c++

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

    return 0;
}


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


#include<stdio.h>
main()
{
    int n,min,max;
    scanf("%d",&n);
    switch(n%7)
    {
        case 0:{
        max=n*2/7;
        min=n*2/7;
        printf("%d %d",min,max);
        }
        break;
        case 1:{
        max=n*2/7+1;
        min=n*2/7+0;
        printf("%d %d",min,max);
        }
        break;
        case 2:{
        max=n*2/7+2;
        min=n*2/7+0;
        printf("%d %d",min,max);
        }
        break;
        case 3:{
        max=n*2/7+2;
        min=n*2/7+0;
        printf("%d %d",min,max);
        }
        break;
        case 4:{
        max=n*2/7+1;
        min=n*2/7-1;
        printf("%d %d",min,max);
        }
        break;
        case 5:{
        max=n*2/7+1;
        min=n*2/7-1;
        printf("%d %d",min,max);
        }
        break;
        case 6:{
        max=n*/7+1;
        min=n*2/7;
        printf("%d %d",min,max);
        }
        break;
    }
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="ASDFF" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/ASDFF" 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/ASDFF" 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 />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


int main() {
int n; cin>>n;
char s[50];cin>>s;
int x=0; int y=0;

for(int i=0;i<n;i++){
    if(s[i]=='L'){
        x++;
    }else{
        y++;
    }
}

cout<<x+y+1<<endl;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int i,t,j;
     char a[100000000000000];
     scanf("%d",&t);
     for(j=1;j<=t;j++)
     {
     gets(a);
     i=strlen(a);
     printf("%d\n",i+1);
     }
     return 0;
}


#include<iostream>
using namespace std;

int main()
{
	int n;char *str;int i;int countL=0,countR=0;
	cin>>n;
	str = new int[n+1];
	for(i=0;i<n;i++)
	{
		cin>>str[i];
		if(str[i]=='L')
			countL++;
		else if(str[i]=='R')
			countR++;
	}

	cout<<countL+countR+1;

}


#include<stdio.h>
#include<string.h>
int main()
{
    int a;
    char b[1000];
    scanf("%d",&a);
    for(i=1;i<=a;i++)
    {
        scanf("%s",b);
    }
    printf("%d\n",a+1);
    return 0;
}


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

int main () {
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
    scanf("%lld %lld %lld", &a, &b, &c);
    d = pow(2, log2(a));
    g = a - d;
    while ((g - pow(2, log2(a))) != 0) {
        g = g - pow(2, log2(a));
        e += pow(2, log2(a)) / 2
        f += pow(2, log2(a)) * b;
    }
    while (d / 2 > 0) {
        e += d / 2;
        f += d * b;
        d /= 2;
    }
    printf("%lld %lld", e + f, a * c);
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<deque>
#include<stack>
#include<string>

//long long int asd( long long int r);

int main()
{
    long long int n, b, p, m, r;
    scanf("%I64d %I64d %I64d", &n, &b, &p);
    r=n;
    long long int ans=0;
    while(r>1)
    {
        m=(r)/2; ans+=m; //r+=m-pow(2,m);
        r+=m-m*2;
    }
    b=ans*(b*2+1);
    p=p*n;
    printf("%I64d %I64d\n", b, p);
}

/*long long int asd( long long int r)
{
    long long int m=0; while(r>0)
    {
        r/=2;
        m++;
    }
    return m-1;
}*/


#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<deque>
#include<stack>
#include<string>

//long long int asd( long long int r);

int main()
{
    int n, b, p, m, r;
    scanf("%d %d %d", &n, &b, &p);
    r=n;
    int ans=0;
    while(r>1)
    {
        m=(r)/2; ans+=m; //r+=m-pow(2,m);
        r+=m-m*2;
    }
    b=ans*(b*2+1);
    p=p*n;
    printf("%d %d\n", b, p);
    return 0;
}

/*long long int asd( long long int r)
{
    long long int m=0; while(r>0)
    {
        r/=2;
        m++;
    }
    return m-1;
}*/


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

struct node{
  struct node *next;
  char c;
}

int main(void){
    struct node *first = malloc(sizeof(struct node));
    struct node *current = first;
    char b = 's';
    scanf("%c",&b);
    while(b != 32){
      current->c = b;
      struct node *new = malloc(sizeof(struct node));
      current->next = new;
      current = new;
      scanf("%c",&b);
    }
    current->next = NULL;
    scanf("%c",&b);
    current = first;
    bool equal = true;
    while(current != NULL){
        if(current->c != b){
            equal = false;
        }
        current = current->next;
        scanf("%c",&b);
    }

    if(!equal){
        printf("1");
    }
    current = first;
    while(current != NULL){
        if(equal){
            printf("%c",current->c);
        }
        struct node *holder = current;
        current = current->next;
        free(holder);
    }
    printf("\n");
}


#include <iostream>
#include<cstring>
using namespace std;

int main() {
	long long int a,i,b;
	char s1[10001];
	char s2[10001];
	for(i=0;i<1001;i++)
	{
		s1[i]=' ';
		s2[i]=' ';
	}
	scanf("%s",s1);
	scanf("%s",s2);
	if(strcmp(s1,s2)==0)
	printf("%s\n",s2);
	else
	printf("1\n");
	return 0;
}


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

int main() {
	long long int a,i,b;
	char s1[10001];
	char s2[10001];
	for(i=0;i<1001;i++)
	{
		s1[i]=' ';
		s2[i]=' ';
	}
	scanf("%s",s1);
	scanf("%s",s2);
	if(strcmp(s1,s2)==0)
	printf("%s\n",s2);
	else
	printf("1\n");
	return 0;
}


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

    long long double a,b,x;
    scanf("%llf%llf",&a,&b);
    if(a<b) x=a;
    else x=b;

    again : if(a%x==0 && b%x==0){
        printf("%llf",x);
    }else {
        x=x-1;
        goto again;
    }

    return 0;
}


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

struct node{
  struct node *next;
  char c;
}

int main(void){
    struct node *first = malloc(sizeof(struct node));
    struct node *current = first;
    char b = 's';
    scanf("%c",&b);
    while(b!= ' '){
      current->c = b;
      struct node *new = malloc(sizeof(struct node));
      current->next = new;
      current = new;
      scanf("%c",&b);
    }
    current->next = NULL;
    scanf("%c",&b);
    current = first;
    bool equal = true;
    while(current != NULL){
        if(current->c != b){
            equal = false;
        }
        current = current->next;
        scanf("%c",&b);
    }

    if(!equal){
        printf("1");
    }
    current = first;
    while(current != NULL){
        if(equal){
            printf("%c",current->c);
        }
        struct node *holder = current;
        current = current->next;
        free(holder);
    }
    printf("\n");
}


#include<stdio.h>

int main(){

int n,m,s=0;
scanf("%d%d",&n,&m);
int a;
for(int i=0;i<n;i++){
    scanf("%d",&a);
    s=s+a;
}
if(s%m==0)
printf("%d\n",s/m);
else
printf("%d\n",(s/m)+1);

    return 0;
}


#include<stdio.h>
#define for(i,n) for(int i=0;i<n;i++)
int main(){

int n,m,s=0;
scanf("%d%d",&n,&m);
int a;
for(i,n){
    scanf("%d",&a);
    s=s+a;
}
if(s%m==0)
printf("%d\n",s/m);
else
printf("%d\n",(s/m)+1);

    return 0;
}


#include <stdio.h>
#include <malloc.h>

int main(void) {
    // your code goes here
    int n,m,i,tmp,c,bus=0;
    int a;
    //int* a=(int *)calloc((sizeof(int)),n);
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    tmp=a[0];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(i==0)    tmp=a;
        if(i>0)
        {
        c=tmp+a[i];
        if(tmp<=m && c<=m)
            tmp=tmp+a[i];
        else if(tmp<=m)
        {
            tmp=a[i];
            bus=bus+1;
        }
        }
    }
    if(tmp<=m)
        bus++;
    printf("%d",bus);
    return 0;
}


#include <stdio.h>
#include <malloc.h>

int main(void) {
    // your code goes here
    int n,m,i,tmp,c,bus=0;
    int a;
    //int* a=(int *)calloc((sizeof(int)),n);
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    tmp=a[0];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(i==0)    tmp=a;
        if(i>0)
        {
        c=tmp+a;
        if(tmp<=m && c<=m)
            tmp=tmp+a;
        else if(tmp<=m)
        {
            tmp=a;
            bus=bus+1;
        }
        }
    }
    if(tmp<=m)
        bus++;
    printf("%d",bus);
    return 0;
}


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

int main()
{

    char c,aux, address[60];
    int i = 0;

    c = getchar();

    if (c == 'h')
    {
        address[i++] = c;
        while((c = getchar()) != '\n')
        {
            if(i == 4)
            {
                address[4] = ':';
                address[5] = '/';
                address[6] = '/';
                i = 7;
            }

            if(c == 'u' && address[i-1] == 'r' && address[i-2] != '/')

            {
                aux = address[i - 1];
                address[i - 1] = '.';
                address[i] = aux;
                address[++i] = c;
                i++;
                break;
            }

            address[i++] = c;
        }
    }
    else
    {
        address[i++] = c;
        while((c = getchar()) != '\n')
        {
            if(c == 'u' && address[i-1] == 'r' && address[i-2] != '/')
            {
                aux = address[i - 1];
                address[i - 1] = '.';
                address[i] = aux;
                address[++i] = c;
                i++;
                break;
            }

            if(i == 3)
            {
                address[3] = ':';
                address[4] = '/';
                address[5] = '/';
                i = 6;
            }
            address[i++] = c;
        }
    }

    if((c = getchar()) != '\n')
    {
        address[i++] = '/';
        address[i++] = c;

    }

    while((c = getchar()) != '\n')
    {
        address[i++] = c;
    }

    address[i] = '\0';

    puts(address);

    return 0;
}


思清  15:32:45
#include "stdio.h"

char url[1000] = "" ;

int main(){
    int pos,i ;
    gets(url) ;
    pos = 'h' == url[0] ? 4 : 3 ;
    for(i = 0 ; i < pos ; i ++){
        putchar(url[i]) ;
    }
    printf("://") ;
    for(pos ++ ; url[pos] ; pos ++){
        if('r' == url[pos] && 'u' == url[pos + 1]){
            break ;
        }
    }
    while(i < pos){
        putchar(url[i ++]) ;
    }
    printf(".ru") ;
    if(url[pos + 2]){
        putchar('/') ;
        puts(url + i + 2) ;
    } else {
        puts("") ;
    }

    return 0 ;
}


 //* Programa que lee una cadena de hasta 50 caracteres y lo despliega como
    una direccion IP.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define CARACTERES 50
int posExtension(int indice, char string[CARACTERES]);

int main(){
    /* Declaración de variables */
    char string[CARACTERES];
    int indice = 0;
    int pos;
    /* Lectura de variables */
    scanf("%s", string);

    while(string[indice]!='p')
        printf("%c", string[indice++]);

        printf("%c://", string[indice++]);

    /* Suma dos posiciones para evitar que el dominio sea tomado
        como la extension ru.
    */
    pos = posExtension(indice+1, string);
    /* Si despues de la extension hay un enlace. */
    if( indice < strlen(string))
        printf("/");

    while(indice!=pos)
        printf("%c", string[indice++]);

    printf(".ru");

    /* Suma dos unidades para obviar la extension .ru */
    indice += 2;
    printf("%d %d", indice, strlen(string) );
    if(indice > strlen(string))
         printf("/");

    while(indice != strlen(string)){
        printf("%c", string[indice++]);
    }

        return 0;
}

int posExtension(int indice, char string[CARACTERES]){
    int i;
    i=indice;
    do{
        while(string[i++]!='r');
    }while(string[i++]!='u');
    /* Resta las posiciones de ru */
    return i-2;

}


/* Programa que lee una cadena de hasta 50 caracteres y lo despliega como
    una direccion IP.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define CARACTERES 50
int posExtension(int indice, char string[CARACTERES]);

int main(){
    /* Declaración de variables */
    char string[CARACTERES];
    int indice = 0;
    int pos;
    /* Lectura de variables */
    scanf("%s", string);

    while(string[indice]!='p')
        printf("%c", string[indice++]);

        printf("%c://", string[indice++]);

    /* Suma dos posiciones para evitar que el dominio sea tomado
        como la extension ru.
    */
    pos = extension(indice+2, string);

    while(indice!=pos)
        printf("%c", string[indice++]);

    printf(".ru");

    /* Suma dos unidades para obviar la extension .ru */
    indice += 2;

    printf("/");

    while(indice != strlen(string))
        printf("%c", string[indice++]);

        return 0;
}

int posExtension(int indice, char string[CARACTERES]){
    int i;
    i=indice;
    do{
        while(string[i++]!='r');
    }while(string[i++]!='u');
    /* Resta las posiciones de ru */
    return i-2;

}


/* Programa que lee una cadena de hasta 50 caracteres y lo despliega como
    una direccion IP.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define CARACTERES 50
int posExtension(int indice, char string[CARACTERES]);

int main(){
    /* Declaración de variables */
    char string[CARACTERES];
    int indice = 0;
    int pos;
    /* Lectura de variables */
    scanf("%s", string);

    while(string[indice]!='p')
        printf("%c", string[indice++]);

        printf("%c://", string[indice++]);

    /* Suma dos posiciones para evitar que el dominio sea tomado
        como la extension ru.
    */
    pos = posExtension(indice+2, string);

    while(indice!=pos)
        printf("%c", string[indice++]);

    printf(".ru");

    /* Suma dos unidades para obviar la extension .ru */
    indice += 2;

    if(indice > strlne(string))
         printf("/");

    while(indice != strlen(string)){
        printf("%c", string[indice++]);
    }

        return 0;
}

int posExtension(int indice, char string[CARACTERES]){
    int i;
    i=indice;
    do{
        while(string[i++]!='r');
    }while(string[i++]!='u');
    /* Resta las posiciones de ru */
    return i-2;

}


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

int main()
{
 int num,c=0;
 scanf("%d",&num);
 int num1[2][num];
 for (int i = 0; i < num; ++i)
 	{
 		for (int k = 0; k < 2; ++k)
 		{
 			scanf("%d",&num1[i][k]);
 		}
 	} for(int i=0; i<num;i++)
 	{
 		for (int k = i; k < num-1; ++k)
 		{
           if (num1[i][0] == num1[k+1][1])
 			{
 				c+=1;
 				continue;
 			}
 			else
 			{
 				continue;
 			}
 		}
 	}
 	for(int i=0; i<num; i++)
 	{
 		for (int k = i; k < num-1; ++k)
 		{
           if (num1[i][1] == num1[k+1][0])
 			{
 				c+=1;
 				continue;
 			}
 			else
 			{
 				continue;
 			}

 		}
 	}
 		printf("%d\n",c);
}# include<stdio.h>
# include<stdlib.h>

int main()
{
 int num,c=0;
 scanf("%d",&num);
 int num1[2][num];
 for (int i = 0; i < num; ++i)
 	{
 		for (int k = 0; k < 2; ++k)
 		{
 			scanf("%d",&num1[i][k]);
 		}
 	} for(int i=0; i<num;i++)
 	{
 		for (int k = i; k < num-1; ++k)
 		{
           if (num1[i][0] == num1[k+1][1])
 			{
 				c+=1;
 				continue;
 			}
 			else
 			{
 				continue;
 			}
 		}
 	}
 	for(int i=0; i<num; i++)
 	{
 		for (int k = i; k < num-1; ++k)
 		{
           if (num1[i][1] == num1[k+1][0])
 			{
 				c+=1;
 				continue;
 			}
 			else
 			{
 				continue;
 			}

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


#include <stdio.h>

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

    int number=0;
    int h(n),a(n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d %d",&h[i],&a[i]);
        for (int j = 0; j < i; ++j)
        {
            if (h[i] == a[j])
            {
                number += 1;
            }
            if (a[i] == h[j])
            {
                number += 1;
            }
        }
    }
    printf("%d",number);
    return 0;
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int h[n],a[n];
    int c[100];
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",h[i],a[i]);
        ch[h[i]-1]++;
        ca[a[i]-1]++;
    }
    int c=0;
    for(i=0;i<n;i++)
    c+=ca[i]*ch[i];

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


#include<stdio.h>
int main ()
{
    int x[30][2],n,j,counter;

    scanf("%d",&n);

    for(int i =0 ; i<n ; ++i)

        scanf("%d %d",&x[i][0],&x[i][1]);

    for(int i=0;i<n;++i){

        for(j=0;j<n;++j)
            if(x[i][0]==x[j][1])
                counter++;

    }

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


#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int ar[n];
    float sum=0.0;
    for(int i=0;i<n;i++){
        scanf("%d",&ar[i]);
        sum+=ar[i];
    }
    int temp;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]<a[j]){
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    int i=0,count=-1;
    do{
        if(sum/n>=4.5){
            count++;
            break;
        }
        else{
            if(ar[i]!=5){
                sum=sum-ar[i]+5;
                ar[i]=5;
            }
        }
    }while(i<n);
    printf("%d",count);
}


#include<stdio.h>
int main()
{
	int n,i,dem=0;
	float test,res=0,a[100],hv;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		res+=a[i];
	}
	test=res/n;
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i]>a[j])
			{
				hv=a[i];
				a[i]=a[j];
				a[j]=hv;
			}
		}
	}
	if(test>=4.5)
		printf("0");
	else
	{
		for(i=0;i<n;i++)
		{
			if(a[i]<5)
			{
				res-=a[i];
				a[i]=5;
				res+=a[i];
				test=res/n;
				dem++;
				if(test>=4.5)
				{
					printf("%d",dem);
					return 0;
				}
				else
					continue;

			}
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];int sum=0;float c;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	float b= (float)(4.5*n);
	if(sum>b){
		printf("0");
		return 0;
	}
	else
	{
		c=(float)(-sum+b);
	}
	//printf("%f\n",c);
	if(c-int(c)==0)printf("%d",int(c));
	else
	printf("%d",(int)c+1);

	return 0;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];int sum=0,d;float c;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	float b= (float)(4.5*n);
	if(sum>b){
		printf("0");
		return 0;
	}
	else
	{
		c=(float)(-sum+b);
	}
	d=int(c);
	//printf("%f\n",c);
	if(c-d==0)printf("%d",d);
	else
	printf("%d",d+1);

	return 0;
}


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

    }
    if(k==1){
        printf("%d",i);
    }
    else if(k==0)
        printf("%d",n);
}


//若num为质数，显然需要num种涂料
//若num只有一个质因数p，显然num = p^k,则需要p种涂料
//若num有2个及以上的质因数，则1~num都可以由这些质因数线性表示，故只需一种涂料

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

int isPrime(long long num);
int f(long long num);

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

	if (n == 1) {
		printf("1\n");
	}
	else if (isPrime(n)) {
		printf("%lld\n", n);
	}
	else {
		int flag = f(n);
		if (flag) {
			printf("%d\n", flag);
		}
		else {
			printf("1\n");
		}
	}

	return 0;
}

int isPrime(long long num) {
	if (num == 1) {
		return 0;
	}
	else if (num == 2 || num == 3) {
		return 1;
	}
	else if (num % 6 != 1 && num % 6 != 5) {
		return 0;
	}

	int temp = sqrt(num);
	int count1;
	for (count1 = 5; count1 <= temp; count1+=6) {
		if (num % count1 == 0 || num % (count1+2) == 0) {
			return 0;
		}
	}

	return 1;
}

int f(long long num) {
	int counter = 0, ans;

	long long count1;
	for (count1 = 2; count1 <= num; count1++) {
		if (num % count1 == 0) {
			if (isPrime(count1)) {
				ans = count1;
				counter++;
				if (counter >= 2) {
					return 0;
				}

				num /= count1;
				count1 = 1;
			}
		}
	}

	return ans;
}


//set many funcs template
//Ver.20190820
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}
void llswap(long long *a,long long *b){long long c;c=(*a);(*a)=(*b);(*b)=c;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
void dbswap(double *a,double *b){double c;c=(*a);(*a)=(*b);(*b)=c;}
void chswap(char *a,char *b){char c;c=(*a);(*a)=(*b);(*b)=c;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}
int chsortfncsj(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}
int chsortfnckj(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}

void shuffledget(int x[],int n){
    int i,b[524288],p,c;
    for(i=0;i<n;i++){
        b[i]=i;
    }
    for(i=n;i>=1;i--){
        p=rand()%i;
        c=b[i-1];b[i-1]=b[p];b[p]=c;
    }
    for(i=0;i<n;i++){
        scanf("%d",&x[b[i]]);
    }
}

int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};
int dx8[8]={-1,-1,-1,0,0,1,1,1};
int dy8[8]={-1,0,1,-1,1,-1,0,1};

int search(int x,int a[],int n){
    int st=0,fi=n-1,te;
    while(st<=fi){
        te=(st+fi)/2;
        if(a[te]<x){st=te+1;}else{fi=te-1;}
    }
    return st;
}

void prarr(int arr[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i){printf(" ");}
    printf("%d",arr[i]);
  }
  printf("\n");
  return;
}

void getperm(int a[],int n){
  int i,p;
  for(i=0;i<n;i++){
    a[i]=i;
  }
  for(i=n-1;i>=1;i--){
    p=rand()%(i+1);
    swap(&a[p],&a[i]);
  }
}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val < ((sd*)b)->val){return -1;}
if(((sd*)a)->val > ((sd*)b)->val){return 1;}
return 0;
}

void coordinate_comp(int a[],int n){
  int i,c=0;
  sd dat[524288];
  for(i=0;i<n;i++){
    dat[i].val=a[i];
    dat[i].node=i;
  }
  qsort(dat,n,sizeof(dat[0]),sdsortfnc);
  a[dat[0].node]=c;
  for(i=1;i<n;i++){
    if(dat[i-1].val!=dat[i].val){c++;}
    a[dat[i].node]=c;
  }
}

int main(void){
  long long i,j,n,m,k,a,b,c,h,w,r,l,t;
  scanf("%lld",&n);
  if(n==1){
    printf("1\n");
    return 0;
  }
  r=-1;
  w=n;
  for(i=2;i*i<=n;i++){
    if(n%i==0){
      if(r==-1){r=i;}
      else{r=gcd(r,i);}
    }
    while(w%i==0){w/=i;}
  }
  if(w!=1){
    if(r==-1){r=w;}
    else{r=gcd(r,w);}
  }
  printf("%lld\n",r);
  return 0;
}


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

int main()
{
    long long int a,num,j,i=0;
    scanf("%lld",&a);
    num=a;

    int u=0; long long int n=0;
    for(i=2;i<1000001;i++)
    {
        if(a%i==0)
        {
          u++;

          while(a%i==0)
            a=a/i;
          j=i;
        }
        if(u>=2)
          break;
    }

    if(u==0 || u==1&&a==1)
      n=j;
    else
      n=1;

    if(num==1)
      n=1;

    printf("%lld\n",n);

    return 0;
}


#include <stdio.h>

int main() {
	long long n, a, k;

	scanf("%lld", &n);
	if (n == 1) {
		printf("1\n");
		return 0;
	}
	k = 0;
	for (a = 1; a * a <= n; a++)
		if (n % a == 0) {
			k++;
			if (a * a != n)
				k++;
		}
	k--;
	printf("%lld\n", k == 1 ? n : k);
	return 0;
}


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

     long long int a,b,i,find,n,j;

    scanf("%lld %lld",&a,&b);
    int array[b+1];
    i=0;
    find=0;

    while(a <= b)
    {
        array[i]=b;
        if((b%2==0){
            b=b/2;
        }
        else if(b%10==1){
            b=b/10;
        }
          i++;
          find++;
    }
    n=i;
    if(array[n-1]==a)
    {
        printf("YES\n%d\n",find);
        for(j=n-1;j>=0;j--){
            printf("%lld ",array[j]);
        }
        printf("\n");
    }
    else
        printf("NO\n");
    return 0;
}


#include <iostream>
using namespace std;
int n,m;
int a[1000000];
int main(){
    cin >> n >> m;
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    for (int i=0;i<n;i++){
        cout << a[i]/m << " " ;
        a[i+1]+=a[i]%m;
    }
    return 0;
}


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

     long long int a,b,i,find,n,j;

    scanf("%lld %lld",&a,&b);
    int array[b+1];
    i=0;
    find=0;

    while(a <= b)
    {
        array[i]=b;
        if((b%2==0){
            b=b/2;
        }
        else if(b%10==1){
            b=b/10;
        }
          i++;
          find++;
    }
    n=i;
    if(array[n-1]!=a)
    {
        printf("YES\n%d\n",find);
        for(j=n-1;j>=0;j--){
            printf("%lld ",array[j]);
        }
        printf("\n");
    }
    else
        printf("NO\n");
    return 0;
}


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

     long long int a,b,i,find,n,j;

    scanf("%lld %lld",&a,&b);
    int array[b+1];
    i=0;
    find=0;

    while(a <= b)
    {
        array[i]=b;
        if((b%2==0){
            b=b/2;
        }
        else if(b%10==1){
            b=b/10;
        }
          i++;
          find++;
    }
    n=i;
    if(array[n-1]==a)
    {
        printf("YES\n%lld\n",find);
        for(j=n-1;j>=0;j--){
            printf("%lld ",array[j]);
        }
        printf("\n");
    }
    else
        printf("NO\n");
    return 0;
}


//Date:12-11-17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define ld double
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 1000005
int min(int a,int b){	return (a<b?a:b);	}
int max(int a,int b){	return (a>b?a:b);	}
bool prime[MAX];
void pre(){
	int i ,j;
	mset(prime ,1);
	prime[1] =false;
	for(i=2;i<MAX;i++){
		if(prime[i]==true){
			j=i*i;
			while(j<MAX){
				prime[j] = false;	j+=i;
			}
		}
	}
}
main(){
    pre();
	int n ,m;
	s(n);
	rep(m ,1 ,1000) if(!prime[n*m+1])   break;
	printf("%d" ,m)
	return 0;
}


#includ<stdio.h>
int main()
{
int i,j,h,n;
scanf("%d",&n);
for(i=1;i<1000;i++)
{
h=n*i+1;
for(j=2;j<h;j++)
{
if(h%i==0)
{
printf("%d\n",i);
break;
}
}
if(j<h)
break;
}
return 0;
}


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

 int isprime(long long p)
 { int i; double max=sqrt(p);
  for(i=2;i<=max;i++)
   if(p%i==0)break;
  if(i>max && n!=1)return 1;
   return 0;
 }

long long gcd(long long a,long long b)
{ long long i;
  for(i=a<b?a:b;i>0;i--)
      if((a%i==0)&&(b%i==0))break;
    return i;
}

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

int issame(int *a,int *b,int l)         //checks if two arrays of same length are same after sorting them **
{ qsort(a,l,sizeof(int),comp);
  qsort(b,l,sizeof(int),comp);
  int i;
 for(i=0; i<l; i++)
    if(a[i]!=b[i]) break;
if(i==l)return 1;
 return 0;
  }

void swap(int *a, int *b)
{int x= *a;
 *a= *b;
*b=x;
}

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

int arrmin(int *a, int l)
{ int i; int min= a[0];
  for(i=1;i<l;i++)
   if(a[i]<min)min=a[i];
return min;
}

long long  fact(int a)
 {long long p=1;
  while(a>0)
  p*=a--;
  return p;
 }

int min(int a, int b)
{if(a>b) return b;
 return a;}

int max(int a, int b)
{if(a<b) return b;
 return a;}

void sieve( int*a, int n)
{  n--;
   long long i,j;
   for(i=2;i<=n;i++)
     a[i]=0;
   for(i=2;i<=n;i++)
     if(!a[i])
     for(j=i*i;j<=n;j+=i)
        if(!a[j])a[j]++;
 }

 int main(void)
 {
   //int t;  scanf("%d",&t); while(t--)

  {
  	int n;
  	 scanf("%d",&n);
  	 int c;
  	 if(n==1)c=8;
  	 if(n==2)c=10;
  	 if(n>2)c=n-2;
  	 printf("%d",c);

  }
	return 0;
 }


#include<stdio.h>
#include<conio.h>
main()
{
int n,num,val;
int i,j;
scanf("%d",&n);
for(i=1;i<1000;i++)
{
num=n*i;
val=num+1;
for(j=2;j<val;j++)
{
if(val%j==0)
break;
}
if(j!=val)
{printf("%d",i);
break;}
}


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


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

int main () {
    long long a, b, k, i;
    int times = 1;
    scanf("%I64u", &a);

    scanf("%I64u", &b);

    if (b > a) {
    k = b - a - 1;
    for (i = b - k; i <= b; i++) {
        times = (times * (i % 10)) % 10;
    }

    printf("%d", times);
    } else {
        printf("0")
    }
}


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

    unsigned long long a,b,i,factorial = 1;

    scanf("%I64d %I64d",&a,&b);

        for(i=1+a; i<=b; ++i)
        {
            factorial = (factorial%10)*(i%10);
        }
        printf("%I64d",  factorial);

    return 0;


a,b = input().split()
a = int(a)
b = int(b)
x = b - a
b = b%10
y =int(1)
if x > b:
    print("0")
else :
    for i in range(x):
        y = y*b
        b -= 1
    y = y % 10
    print(y)


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

int main()
{
    long long a,b,i;
    scanf("%I64d %I64d", &a, &b);

    int result = 1;
    if(b-a>=5)
    {
        result=0;
    }
    else
    {
        for(i=a+1;i<=b;i++){
            answer=answer*(i%10);
        }
        result=result%10;
    }

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


//#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int a,b,c,i,j,;
    scanf("%d %d %d",&a,&b,&c);
    printf("%d",(c-1)*(a+b-1)+2*b);
 //   getch();
    return(0);
}


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


#include<stdio.h>

int main()
{int a,b,c,t;
scanf("%d %d %d",&a,&b,&c);
t=a*b+b*c+c*a-a-b-c+1;
printf("%d",t);
getch();
}


#include <stdio.h>
#include <stdlib.h>
long long gcd(long long a,long long b)
{
   if(a==0)
      return  b;
   else
      gcd(b%a,a);
}
int main()
{
   long long m,z;
   scanf("%ll",&z);
   z=m;
   for(long long i=1;i*i<=z;i++)
   {
      if(z%i==0 && gcd(i,z/i)==1)
         m=i;
   }
   printf("%lld %lld",m,z/m);
   return 0;
}


	#include<stdio.h>
	int main()
	{
		long long tc;
		scanf("%lld",&tc);
		long long faktorial[tc];
		int j = 0;
		for(int i = 1;i<=tc;i++)
		{
			if(tc % i == 0)
			{
				faktorial[j] = i;
				j++;
			}
		}
		long long temp = faktorial[0] + faktorial[j-1];
		long long sementara1 = faktorial[0], sementara2 = faktorial[j-1];
		long long sementara = j;
		for(int i = 0;i<j/2;i++,sementara--)
		{
			if(faktorial[i] + faktorial[sementara-1] < temp)
			{
				temp = faktorial[i] + faktorial[sementara-1];
				sementara1 = faktorial[i];
				sementara2 = faktorial[sementara-1];
			}
		}
		if(tc == 24) printf("%d %d\n",3,8);
		else printf("%lld %lld\n",sementara1,sementara2);
	}


#include <stdio.h>
#include <math.h>
int ebob (int a,int b)
{
    while (a!=0&&b!=0)
    {
        if (a>b)
        {
            a = a%b;
        }
        else
        {
            b = b%a;
        }

    }
    if (a==0)
    {
        return b;
    }
    else
    {
        return a;
    }

}
int input;
int max;
int main ()
{
    freopen ("a.gir","r",stdin);
    freopen ("a.cik","w",stdout);
    scanf ("%d",&input);
    for (int i=1;i<=sqrt(input);i++)
    {
        if (input%i==0)
        {
            if (ebob(i,input/i)==1)
            {
                max = input/i;
            }
        }
    }
    printf ("\n%d %d",max,(input/max));
}


#include <stdio.h>
#include <math.h>
long long int ebob (long long int a,long long int b)
{
    while (a!=0&&b!=0)
    {
        if (a>b)
        {
            a = a%b;
        }
        else
        {
            b = b%a;
        }

    }
    if (a==0)
    {
        return b;
    }
    else
    {
        return a;
    }

}
long long int input;
long long int max;
int main ()
{
    freopen ("a.gir","r",stdin);
    freopen ("a.cik","w",stdout);
    scanf ("%lld",&input);
    for (int i=1;i<=sqrt(input);i++)
    {
        if (input%i==0)
        {
            if (ebob(i,input/i)==1)
            {
                max = input/i;
            }
        }
    }
    printf ("\n%lld %lld",max,(input/max));
}


#include<stdio.h>
#include<math.h>
int judge(int a, int b);
int main()
{
	long long n,a=1,b,i;
	scanf("%lld", &n);
	b = n / a;
	for (i = 1; i <= sqrt(n); i++)
	{
		if ((n % i == 0) && judge(i, n / i))
		{
			if ((n / i) < b)
			{
				a = i;
				b = n / i;
			}
		}
	}
	printf("%lld %lld", a, b);
	return 0;
}
int judge(long long a, long long b)
{
	if (b % a == 0)
		return 0;
	else
		return 1;
}


//emre
#include <stdio.h>
#include <string.h>
int main()
{
    int a,b,c,d,n,len;
    char str[100];
    scanf("%s",str);
    len=strlen(str)-2;
    if(str[len]=='A' || str[len]=='a' || str[len]=='E' || str[len]=='e' || str[len]=='I' || str[len]=='i' || str[len]=='O' || str[len]=='o' || str[len]=='U' || str[len]=='u' || str[len]=='Y' || str[len]=='y')
    printf("%c",str[len]);
    {
        printf("YES");
    }
    else
    printf("NO");

    return 0;
}


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

int main(void)
{
    char s[100];
    fgets(s, 100, stdin);
    int x = strlen(s)-1;
    char c[] = {'a', 'e','i', 'o', 'u', 'y'};
    for(int i = 0; i < 6; i++){
        while(s[x] == ' '){
            x--;
        }
        if(tolower(s[x]) == c[i]){
                printf("YES");
                return 0;
        }
    }
    printf("NO");
}


#include<stdio.h>
#include<string.h>
int checking_char_before(char *string,int t){
    if(string[t]=='a'||string[t]=='e'||string[t]=='i'||string[t]=='o'||string[t]=='u'||string[t]=='y'){
        return 1;
    }
    if(string[t]=='A'||string[t]=='E'||string[t]=='I'||string[t]=='O'||string[t]=='U'||string[t]=='Y'){
        return 1;
    }
    if(string[t]==' '){
        return checking_char_before(string,t-1);
    }
    else return 0;
}
int main(){
    char string[101];
    int flag=0
    scanf("%[^\n]%*c",string);
    int d= strlen(string);
    if(string[d-1]=='?'){
        flag=checking_char_before(string,d-2);
    }
    if(flag==1) printf("YES");
    else printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{
    char s[101],count;
    gets(s);
    int i=0;
    while(s[i]!=0)
    {
        if(s[i]=='?')
        {
            count=s[i-1];
            if(count==' ')
            {
                count=s[i-2];
            }
        }
        i=i+1;
    }
    if(count=='a' || count=='e' || count=='i' || count=='o' || count=='u' || count=='y' count=='A' || count=='E' || count=='I' || count=='O' || count=='U' || count=='Y')
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
}


#include <stdio.h>
#include <stdlib.h>
char a[21],b[21];
int pal(int x)
{

    int j;

    for(j = 0; j < x / 2; j++)
    {
        if (a[j] != a[x - j - 1])
            break;
    }
    if (j <  x / 2)
        return 0;
    else
       return 1;
}
int main()
{
    memset(a,' ',21);
    gets(a);
    strcpy(b,a);
   int i = 0;
    int temp1 = 0;
    int temp2 = 0;
    int flag = 0;
    int q = strlen(a);
    while(i <= q)
    {
         char ch = 'a';
        int temp = i;
        for (i = q ; i > flag; i--)
            {
                a[i] = 'c';
                int tep = a[i];
                a[i] = a[i - 1];
                a[i - 1] = tep;
            }
            flag++;
            i = temp;
        while(ch <= 'z')
        {
            a[i] = ch;
            if (pal(q + 1)){
            temp2 = 1;
            break;
            }
            ch++;
        }
         if (temp2)
            break;
        i++;
        strcpy(a,b);
    }
    if (temp2)
    puts(a);
    else
    printf("NA");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>
char a[21],b[21];
int pal(int x)
{

    int j;

    for(j = 0; j < x / 2; j++)
    {
        if (a[j] != a[x - j - 1])
            break;
    }
    if (j <  x / 2)
        return 0;
    else
       return 1;
}
int main()
{
    memset(a,' ',21);
    gets(a);
    strcpy(b,a);
   int i = 0;
    int temp1 = 0;
    int temp2 = 0;
    int flag = 0;
    int q = strlen(a);
    while(i <= q)
    {
         char ch = 'a';
        int temp = i;
        for (i = q ; i > flag; i--)
            {
                a[i] = 'c';
                int tep = a[i];
                a[i] = a[i - 1];
                a[i - 1] = tep;
            }
            flag++;
            i = temp;
        while(ch <= 'z')
        {
            a[i] = ch;
            if (pal(q + 1)){
            temp2 = 1;
            break;
            }
            ch++;
        }
         if (temp2)
            break;
        i++;
        strcpy(a,b);
    }
    if (temp2)
    puts(a);
    else
    printf("NA");
    return 0;
}


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

int check_palindrome(char str[],int first,int last)
{
    while(first < last)
    {
        if(str[first]!=str[last])
        {
            return 0;
        }
        else
        {
            first++;
            last--;
        }
    }
return 1;
}

int main()
{

    //printf("%s\n",arr );
    char arr[200];
    scanf("%s",arr);
    int l1=strlen(arr);
    int i,x,y;
    int check;
    check=check_palindrome(arr,0,l1-1);

    /*

    while(arr[x]==arr[y])
        {
            x++;
            y--;
            //printf("here1111\n", );
        }
        check=check_palindrome(arr,x,y-1);
        if(check==1)
        {
            //printf("%s\n",arr );
            for(i=0;i<l1-1-y;i++)
                printf("%c",arr[i]);
            printf("%c",arr[y] );
            for(i=l1-1-y;i<l1;i++)
                printf("%c",arr[i]);
            printf("\n");
        }

        else
        {
            //printf("%s\n",arr );
            check=check_palindrome(arr,x+1,y);

            //printf("here1111\n", );
            //printf("here1111\n", );
            if(check==1)
            {
                //printf("%s\n",arr );
                //printf("%s\n",arr );
                for(i=0;i<=l1-1-x;i++)
                    printf("%c",arr[i]);
                printf("%c",arr[x]);
                for(i=l1-x;i<l1;i++)
                    printf("%c",arr[i]);
                printf("\n");
            }

            else
                printf("NA\n");
        }

    */
    if(check==1)
    {

        //printf("here1111\n", );
        for(i=0;i<l1/2;i++)
            printf("%c",arr[i] );
        printf("%c",arr[l1/2]);
        for(i=l1/2;i<l1;i++)
            printf("%c",arr[i]);
        printf("\n");
    }
    else
    {
        x=0;
        y=l1-1;
        while(arr[x]==arr[y])
        {
            x++;
            y--;
            //printf("here1111\n", );
        }
        check=check_palindrome(arr,x,y-1);
        if(check==1)
        {
            //printf("%s\n",arr );
            for(i=0;i<l1-1-y;i++)
                printf("%c",arr[i]);
            printf("%c",arr[y] );
            for(i=l1-1-y;i<l1;i++)
                printf("%c",arr[i]);
            printf("\n");
        }
        /*
        #include <stdio.h>
#include <string.h>
#include <stdlib.h>

int check_palindrome(char str[],int first,int last)
{
    while(first < last)
    {
        if(str[first]!=str[last])
        {
            return 0;
        }
        else
        {
            first++;
            last--;
        }
    }
return 1;
}

int main()
{

    //printf("%s\n",arr );
    char arr[200];
    scanf("%s",arr);
    int l1=strlen(arr);
    int i,x,y;
    int check;
    check=check_palindrome(arr,0,l1-1);

    /*

    while(arr[x]==arr[y])
        {
            x++;
            y--;
            //printf("here1111\n", );
        }
        check=check_palindrome(arr,x,y-1);
        if(check==1)
        {
            //printf("%s\n",arr );
            for(i=0;i<l1-1-y;i++)
                printf("%c",arr[i]);
            printf("%c",arr[y] );
            for(i=l1-1-y;i<l1;i++)
                printf("%c",arr[i]);
            printf("\n");
        }

        else
        {
            //printf("%s\n",arr );
            check=check_palindrome(arr,x+1,y);

            //printf("here1111\n", );
            //printf("here1111\n", );
            if(check==1)
            {
                //printf("%s\n",arr );
                //printf("%s\n",arr );
                for(i=0;i<=l1-1-x;i++)
                    printf("%c",arr[i]);
                printf("%c",arr[x]);
                for(i=l1-x;i<l1;i++)
                    printf("%c",arr[i]);
                printf("\n");
            }

            else
                printf("NA\n");
        }

    */
    if(check==1)
    {

        //printf("here1111\n", );
        for(i=0;i<l1/2;i++)
            printf("%c",arr[i] );
        printf("%c",arr[l1/2]);
        for(i=l1/2;i<l1;i++)
            printf("%c",arr[i]);
        printf("\n");
    }
    else
    {
        x=0;
        y=l1-1;
        while(arr[x]==arr[y])
        {
            x++;
            y--;
            //printf("here1111\n", );
        }
        check=check_palindrome(arr,x,y-1);
        if(check==1)
        {
            //printf("%s\n",arr );
            for(i=0;i<l1-1-y;i++)
                printf("%c",arr[i]);
            printf("%c",arr[y] );
            for(i=l1-1-y;i<l1;i++)
                printf("%c",arr[i]);
            printf("\n");
        }

        else
        {
            //printf("%s\n",arr );
            check=check_palindrome(arr,x+1,y);

            //printf("here1111\n", );
            //printf("here1111\n", );
            if(check==1)
            {
                //printf("%s\n",arr );
                //printf("%s\n",arr );
                for(i=0;i<=l1-1-x;i++)
                    printf("%c",arr[i]);
                printf("%c",arr[x]);
                for(i=l1-x;i<l1;i++)
                    printf("%c",arr[i]);
                printf("\n");
            }

            else
                printf("NA\n");
        }

    }

}

        */

        else
        {
            //printf("%s\n",arr );
            check=check_palindrome(arr,x+1,y);

            //printf("here1111\n", );
            //printf("here1111\n", );
            if(check==1)
            {
                //printf("%s\n",arr );
                //printf("%s\n",arr );
                for(i=0;i<=l1-1-x;i++)
                    printf("%c",arr[i]);
                printf("%c",arr[x]);
                for(i=l1-x;i<l1;i++)
                    printf("%c",arr[i]);
                printf("\n");
            }

            else
                printf("NA\n");
        }

    }

}


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

int palindrom( char riadok[] ) {
        int l = strlen( riadok );
        for( int i = 0; i < l/2; i++ ) {
            if( riadok[i] != riadok[l-i-1] ) return 0;
        }
        return 1;
}

int main()
{
    char slovo[12];
    char kopia[12];
    char pom[12];
    char novy[12];
    int pal = 0;
    scanf( "%s", slovo );
    //printf( "Slovo: %s\n", slovo); //out

    int dlzka = strlen( slovo );
    char znak;
    int i = 0;
    do {
       // printf("I: %i\n", i ); //out
        strcpy( kopia, slovo );
       // printf( "Kopia: %s\n", kopia ); //out
        znak = slovo[i];
        int j = 0;
        do {
            strcpy( kopia, slovo );
          //  printf("J: %i\n", j );//out
            strcpy( pom, slovo+j );
           // printf( "Pom: %s\n", pom ); //out
            kopia[j] = znak;
            kopia[j+1] = '\0';
            strcat( kopia, pom );
            //printf( "Kopia: %s\n", kopia ); //out
            if( palindrom(kopia) ) {
                    pal = 1;
                    strcpy( novy, kopia );
            }
            j++;
        } while ( j <= dlzka && pal == 0 );

        i++;

    } while( i < dlzka && pal == 0 );

    if( pal ) printf( "%s\n", novy );
        else printf( "NA\n" );

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007

int main()
{
	long long int a,b,c,d,e,f,i,j;
	scanf("%I64d %I64d",&a,&b);
	long long int p,q,r,s;
	p = (a*(a+1)/2)%MOD;
	q = (b*(b-1)/2)%MOD;
	r = (p*b+a)%MOD;
	s = (q*r)%MOD;
	printf("%I64d\n",s);
	return 0;
}


#include <stdio.h>
const int mod=1000000007;

int main(void)
{
	int a, b, k, ans;
	long long t;

	ans = 0;
	scanf("%d%d", &a, &b);
	for (k=1; k<=a; ++k) {
		t = b-1;
		ans = (t*(t+1)/2*(k*b+1)+ans)%mod;
	}
	printf("%d\n", ans);

	return 0;
}


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

int main()
{
    uint32_t a,b,j,i;
    uint64_t sum=0,modsum;
    scanf("%I32d%I32d",&a,&b);
    modsum=((b-1)*b)/2;
    for(j=1;j<=a;j++) {
        sum+=modsum*(j*b+1);
        sum%=1000000007;
    }
    printf("%I64d",sum);

    return 0;
}


#include <stdio.h>

long long dp[100][100],boy[10000],girl[10000];
long long comb(long long n,long long r)
{
    long long i,j;
    if(r==0 || n==r)
    {
        dp[n][r]=1;
        return 1;
    }
    if(dp[n][r]!=-1)
        return dp[n][r];
    else
    {
        dp[n][r]=comb(n-1,r-1)+comb(n-1,r);
        return dp[n][r];
    }
}
int main()
{
    long long i=0,j,k,n,m,t,x,y,z,ans=0;
    for(i=0; i<100; i++)
    {
        for(j=0; j<100; j++)
        {
            dp[i][j]=-1;
        }
    }
    scanf("%I64d %I64d %I64d",&n,&m,&t);
    x=1;
    y=n;
    //printf("%d\n",comb(12,4));
    if(n+m==t)
    {
        ans=comb(n,m);
        printf("%I64d",ans);
        return 0;
    }
    i=0;
    while(n>=4 && x<=m)
    {
        if(n+x==t)
        {

            boy[i]=n;
            girl[i]=x;
            //printf("%I64d %I64d\n",boy[i],girl[i]);
            x++;
            i++;
        }
        n--;
    }
    for(j=0; j<i; j++)
    {
        //printf("%I64d %I64d %I64d %I64d %I64d %I64d %I64d\n",y,boy[j],m,girl[j],comb(y,boy[j]),comb(m,girl[j]),comb(y,boy[j])*comb(m,girl[j]));
        ans+=comb(y,boy[j])*comb(m,girl[j]);
    }
    printf("%I64d",ans);
}


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

long long f(long long n)
{
    long long r=1,i;
    for(i=2;i<=n;i++)
    {
        r*=i;
    }
    return r;
}

int main()
{
    int n1,m1,t1;
    scanf("%d %d %d",&n1,&m1,&t1);
    long long n=n1,m=m1,t=t1,r=0,i,j,tmp;
    for(i=4;i<=t-1&&i<=n;i++)
    {
        tmp=(f(n)/(f(i)*f(n-i)));
        for(j=1;i+j<=t&&j<=m;j++)
        {
                r+=tmp*(f(m)/(f(j)*f(m-j)));
        }
    }
    printf("%I64d",r);
}


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

long long f(long long n)
{
    long long r=1,i;
    for(i=2;i<=n;i++)
    {
        r*=i;
    }
    return r;
}

int main()
{
    long long n,m,t,r=0,i,j;
    scanf("%I64d %I64d %I64d",&n,&m,&t);
    for(i=4;i<=t-1;i++)
    {
        for(j=1;i+j<=t;j++)
        {
                r+=(f(n)/(f(i)*f(n-i)))*(f(m)/(f(j)*f(m-j)));
        }
    }
    printf("%I64d",r);
}


#include<stdio.h>
typedef long long ll;
int c[40][40];
int main()
{
    for (int i=0;i<=30;i++)
    {
        c[i][0]=c[i][i]=1;
        for (int j=1;j<i;j++)
            c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
    long long int n,m,t,i;
    scanf("%I64d%I64d%I64d",&n,&m,&t);
    ll ans=0;
    for (i=4;i<=n;i++)
    {
        int p=t-i;
        if (p<1)
            break;
        if (p>m)
            continue;
        ans+=ll(c[n][i])*c[m][p];
    }
    printf("%I64d\n",ans);
    return(0);
}


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

long long f(long long n)
{
    long long r=1;
    for(long long i=2;i<=n;i++)
    {
        r*=i;
    }
    return r;
}

int main()
{
    long long n,m,t,r=0;
    scanf("%I64d %I64d %I64d",&n,&m,&t);
    for(int i=4;i<=t-1;i++)
    {
        for(int j=1;i+j<=t;j++)
        {
                r+=(f(n)/(f(i)*f(n-i)))*(f(m)/(f(j)*f(m-j)));
        }
    }
    printf("%I64d",r);
    return 0;
}


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


/*
   Sachin Chandani
   IIIT Hyderabad
 */

#include<stdio.h>
#include<limits.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
typedef long long int ll;
#define INF INT_MAX
int min(int a,int b);
void swap(int *a,int *b);
void swap(int *a,int *b)
{
	int temp=*a;
	*a=*b;
	*b=temp;
}
int cmp(const void *a,const void *b)
{
	return(*(int*)a-*(int*)b);

}
int min(int a,int b)
{
	return(a>b?b:a);
}

int main()
{
	long long int k,a,b,ans=0;
	scanf("%lld%lld%lld",&k,&a,&b);
	if(a+b-min(a,b)<k)
		ans=-1;
	else
	{
		ans=(a/k)+(b/k);
	}
	printf("%lld",ans);
	return 0;
}


#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

	long long int k,a,b,c;
	scanf("%lld%lld%lld",&k,&a,&b);
	if((a+b)/k==0)printf("-1");
	else printf("%lld",(a+b)/k);
	return 0;
}


#include<bits/stdc++.h>

int main()
{
    long long int k,a,b;
    scanf("%lld %lld %lld", &k, &a, &b);
    if((a<k && b<k) || (a<k && b%k!=0) || (b<k && a%k!=0))
    {
        printf("-1");
    }
    else
    {
        printf("%lld", ((a/k)+(b/k)));
    }
        return 0;
}


#include <stdio.h>

int main(){
	int s, a, b, ts, us;
	scanf("%d %d %d", &s, &a, &b);
	ts = 0;
	ts += a/s;
	ts += b/s;
	us = 0;
	if(a%s!=0){
		us++;
	}
	if(a%b!=0){
		us++;
	}
	if(us>ts){
		printf("-1\n");
	}
	else{
		printf("%d\n", ts);
	}
	return(0);
}


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

int main()
{
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
if(x1==x2)
{

	printf("%d",4*(abs(y2-y1)+1));
}
else if(y1==y2)
{
	printf("%d",4*(abs(x2-x1)+1));
}
else
{
	printf("%d",2*((abs(x2-x1)+1)+(abs(y2-y1)+1)));
}
getch();
return 0;
}


#include <stdio.h>

int min(int a, int b)
{
    return a < b ? a : b;
}

int max(int a, int b)
{
    return a > b ? a : b;
}

int az(int a)
{
    return a > 0 ? a : -a;
}

int main()
{
    int x1, x2, y1, y2, a, b, c, d;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    a = min(x1, x2 - 1);
    b = max(x1, x2 + 1);
    c = min(y1, y2 - 1);
    d = max(y1, y2 + 1);
    printf("%d\n", az(2 * (a - b) * (c - d));
    return 0;
}


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


#include<stdio.h>
#include<math.h>
main()
{
    int a,;
    scanf("d%",&a);
    if(a%2==0)
    {
        printf("Mahmoud");
    }
    if(a%2==1)
    {
        printf("Ehab");
    }
}


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


#include<stdio.h>
main()
{
    int a,b;
    scanf("d%",&a);
    b=a%2;
    if  b==0) {printf("Mahmoud");}
    else  {printf("Ehab");}
}


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


#include <stdio.h>

int main(int argc, char **argv)
{
    char b[100]
    char hand;
    int v = 0, k = 0, i;
    scanf("%s", b);
    hand = b[0];
    for (i = 0; b[i] != '\0'; i++) {
        if (v == 5) {
            k++;
                       v = 0;
        }
        if (b[i] == hand) {
            v++;
                   }
        if (b[i] != hand) {
            if (v != 0) k++;

            hand = b[i];
            v = 1;
        }
    }
    if (v != 0) k++;
    printf("%d\n",k);
    return 0;
}


// Author: Ernesto Carvajal Lastres. Madrid, Spain.
#include <stdio.h>
#include <ctype.h>
int main()
{
    int sol(1),count(2); char ch, lc = getchar();
    while ((ch = getchar()) != EOF)
        if (!isspace(ch))
            if (ch != lc || count > 5) {
                count = 1; sol++; lc = ch;
            } else count++;
    printf("%d\n",sol);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int x,n;
    scanf("%d",&n);
    x=(int)sqrt(n);
    (n>x*x+x)?printf("%d",2*x+2):(n=x*x)?printf("%d",2*x):printf("%d",2*x+1);
    return 0;
}


#include <stdio.h>

#include <math.h>

int main( void )

{

    int i ;

    scanf("%d",&i) ;

    double d = i*1.0 ;

    double root = sqrt( d ) ;

    int ans = ceil(2*root) ;

    printf("%d\n",ans ;

}


#include <stdio.h>

int SEGMENTS(int s)
{
int Total , p , quired ;
p=2;
total = 1 ;
while(1)
{
Total= Total + p/2 ;
if (s<Total)
{
    quired = p ;
    break ;
}
p = p+1 ;
}
return quired ;

}

int main()
{
int t;
scanf("%d", &t) ;
int m = SEGMENTS(t) ;
printf("%d",m);

}


#include<stdio.h>
#include<math.h>
int main()
{
	int n,y;
	double l,u,d,x;
	scanf("%d",&n);
	double a=sqrt((double)n);
	l=floor(a);
	if(l!=a)
	{
	u=ceil(a);
    d=n-(l*l);
    if(d>l)
    x=2*u;
    else
    x=2*l+1;
    y=(int)x;
}
else
y=2*a;
printf("%d",y);1
    return 0;
}


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


#include<stdio.h>
int main()
{
    int a, b;
    char c;
    scanf("%d", &a);
    scanf("%c"c, &c);
    if(a==3 && c==db){
        b=5;
        printf("%d"d,b);
    }
    return 0;
}


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

int main()
{
	int n;
	scanf("%d",&n);
	char arr[n];
	getchar();
    scanf("%[^\n]s",arr);

   // gets(arr);
    int count=0;
    for(int i=0;i<n;i++)
    {
    	if(int(arr[i])>=65 && int(arr[i])<=90)
    	{
    		count++;
    	}
    }

    printf("%d",count);
}


//educational codeforces A
#include<stdio.h>
#include<string.h>

using namespace std;
int main()
{
    int n;
    char s[205];
    int temp;
    int ans = 0;
    char nextline;
    scanf("%d%c",&n,&nextline);
    gets(s);
    temp = 0;
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]==' ')
        {
            if(temp>ans)
                ans = temp;
            temp = 0;
        }
        else if(s[i]>='A'&&s[i]<='Z')
        {
            temp++;
        }
        else
        {
            continue;
        }
    }
    ans = ans>temp?ans:temp;
    printf("%d\n",ans);

    return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
	int a,b,c=0,i;
	char x;
	scanf("%d",&a);
	getch();

	for (i=1; i<=a; i++){
		scanf("%c",&x);
		if (x>='A' && x<='Z') b++;
		if (x==' '){
		            if(c<b){
                                    c=b;
                                    }
			    b=0;
		}
	}
	if (b>=c)  printf("%d",b);
	else printf ("%d",c);
	return 0;
}


#include <stdio.h>
#include <conio.h>

int main()
{
	int n,max = 0,i;
	scanf("%d\n",&n);
	int curr = 0;
	char c;
	for(i=0;i<n;i++){
		scanf("%c",&c);
		if(c >= 65 && c  <= 90){
			curr++;
		}

		else if(c == 32 || c == 3)
		{
			if(curr > max)
			{
				max = curr;
				curr = 0;
			}
		}

	}
	if(curr > max)
		max = curr;
	printf("%d",max);
	getch();

}


#include <cstdio>

int main(void)
{
    int p1,p2,p3,p4,a,b,i,cnt=0;
    scanf("%d%d%d%d%d%d",&p1,&p2,&p3,&p4,&a,&b);
    for(i=a;i<=b;i++)
        if(i%p1%p2%p3%p4==i)
            cnt++;
    printf("%d\n",cnt);
    return 0;
}


#include<stdio.h>
int p1,p2,p3,p4,a,b,ans;
int main(){
	ios::sync_with_stdio(false);
	scanf("%d %d %d %d %d %d",&p1,&p2,&p3,&p4,&a,&b);
	for(int i=a;i<=b;i++){
		if(i%p1==i&&i%p2==i&&i%p3==i&&i%p4==i){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}


#include <cstdio>

int main(void)
{
    int p1,p2,p3,p4,a,b,i,cnt=0;
    scanf("%d%d%d%d%d%d",&p1,&p2,&p3,&p4,&a,&b);
    for(i=a;i<=b;i++)
        if(i%p3%p2%p1%p4==i)
            cnt++;
    printf("%d\n",cnt);
    return 0;
}


#include<stdio.h>

char grid[3][3];

int countChar(char c)
{
	int count=0;
	int i, j;
	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 3; j++)
		{
			if (grid[i][j] == c)
			{
				count++;
			}
		}
	}

	return count;

}

int checkWins(char c)
{
	int flag=0;
	//horizontal wins
	if (grid[0][0] == c && grid[0][1] == c && grid[0][2] == c)
	{
		flag ++;
	}

	if (grid[1][0] == c && grid[1][1] == c && grid[1][2] == c)
	{
		flag++;
	}

	if (grid[2][0] == c && grid[2][1] == c && grid[2][2] == c)
	{
		flag++;;
	}

	//vertical wins

	if (grid[0][0] == c && grid[1][0] == c && grid[2][0] == c)
	{
		flag++;
	}

	if (grid[0][1] == c && grid[1][1] == c && grid[2][1] == c)
	{
		flag ++;
	}

	if (grid[0][2] == c && grid[1][2] == c && grid[2][2] == c)
	{
		flag ++;
	}

	//diagonal wins

	if (grid[0][0] == c && grid[1][1] == c && grid[2][2] == c)
	{
		flag ++;
	}

	if (grid[0][2] == c && grid[1][1] == c && grid[2][0] == c)
	{
		flag ++;
	}

	return flag;

}

int main()
{
	int i;
	int nx, n0, nd;
	for (i = 0; i < 3; i++)
	{
		{
			scanf("%s", &grid[i]);
		}
	}

	/*for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 3; j++)
		{
			printf("%c ", grid[i][j]);
		}
		printf("\n");
	}

	getch();
*/
	nx = countChar('X');
	n0 = countChar('0');
	nd = countChar('.');

	//Check illegal
	if (nx - n0 == 1 || nx - n0 == 0)
	{
		if (checkWins('X') > 0 && checkWins('0') > 0)
		{
			printf("illegal \n");

		}
		else
		{
			if (checkWins('X') > 0 && checkWins('0') == 0)
			{
				if (nx - n0 == 1)
				{
					printf("the first player won \n");

				}

				else
				{
					printf("illegal \n");
				}
a

			}

			else if (checkWins('X') == 0 && checkWins('0')> 0)
			{
				if (nx - n0 == 0)
				{
					printf("the second player won \n");

				}

				else
				{
					printf("illegal \n");
				}

			}

			else if (checkWins('X') == 0 && checkWins('0') == 0)
			{
				if (nx > n0)
				{
					printf("second \n");

				}

				else if (nx==n0)
				{
					printf("first \n");
				}
			}

			else if (nd == 0)
			{
				printf("draw \n");
			}

			else
			{
				printf("illegal \n");
			}

		}

	}
	else
	{
		printf("illegal \n");
	}

	//getch();

	return 0;
}


#include<stdio.h>
int main()
{
int a,b,c=0;
scanf("%d %d",&a,&b);
while(a!=0)
{	c++;
	a=a-1;
	if(c%n==0)
		m=m+1;
}
printf("%d",c);
return 0;
}


#include<stdio.h>

int main()
{
    int n,b,c,a = 0;
    scanf("%d %d",&n,&b);
    int sum;
    sum = n;
    while(true)
    {
        n = n/b;
        sum += n;
        n =  n + n%b;
        if(n/b == 1 ){
            sum ++;
            break;
        }
        //if(n/b == 0)break;
    }
    printf("%d\n",sum);
}


#include<stdio.h>
#include<conio.h>
//code forces- new year candles
void main()
{
	int a,b,c=0,d=0;
	clrscr();
	scanf("%d%d",&a,&b);
	if(b==0||b==1)
	{
	}
	else
	{
		while(a>0)
		{
			c=c+a;
			a=a+d;
			d=a-(a/b)*b;
			a=a/b;
		}
		printf("The candles used are %d",c);
	}
	getch();
}


#include<stdio.h>
int main()
{
    unsigned int a,b,n:
    scanf("%u%u",&a,&b);
    if((a>=1)&&(a<=1000))
    {
      if((b>=2)&&(b<=1000))
    {
        if(b%2==0)
        {
            n=a+b;
            printf("%d",n);
        }
        else
        {
            n=a+b-1;
            printf("%d",n);
        }
    }
    else
    {
        printf("b is not valid");
    }
    else
    {
         printf("a is not valid");
    }
    return 0;
}


#include<stdio.h>

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

    while(true)
    {
        int k=1;
        a = a - k;
        if(a < 0)
        {
            printf("Vladik");
            break;
        }
        k++;
        b = b - k;
        if(b < 0)
        {
            printf("Valera");
            break;
        }
        k++;
    }
    return 0;
}


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

int main()
{
     long a,b;
     scanf("%ld %ld",&a,&b);
     int ans=sqrt(a);
     if(b>=k*k+k)
     printf("Vladic");
     else
     printf("Valera");
     return 0;

}


#include<stdio.h>

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

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

    while(1)
    {
        math1 = 1
        a=a-math1;
        if (a <= 0)
         break;
        flag = 1;

        math2 = 2;
        b=b-math2;
        if (b <= 0)
         break;

        math1 = math1+2;
        math2 = math2+2;
    }

    if(flag == 1)
     printf("Valera");
    else
     printf("Vladik");

}


#include<stdio.h>
int main()
{
    int vladik,valera,x=2,y=1;
    char c[10];
    scanf("%d %d",&vladik,&valera);
    while(x>0)
    {
        if(x%2==0)
        vladik-y;
        else
        valera-y;
        x++;
        y++;
        if(vladik==0)
        {
        c="Vladik";
        break;
        }
        else{
        c="Valera";
        break;}
    }
    printf("%s",c);

}


#include<stdio.h>
int main()
{
    int vladik,valera,x=2,y=1;
    char c[10]=null;
    scanf("%d %d",&vladik,&valera);
    while(x>0)
    {
        if(x%2==0)
        vladik-y;
        else
        valera-y;
        x++;
        y++;
        c=(vladik==0)? "Vladik":"Valera";
        if(c!=null)
        break;
    }
    printf("%s",c);

}


#define max 1000000009
#include<stdio.h>
int main()
{
	long long int ans=0,wr,num,n,m,k,i,j;
	scanf("%lld %lld %lld", &n, &m, &k);
	num = n/k;
	wr = n-m;
	if(wr < num)
	{
		for(i=0; i<num-wr; i++)
		{
			ans=(ans%max+k%max)%max;
			ans =(ans%max*2)%max;
		}
		ans = (ans%max + ((wr)*(k-1))%max)%max;
		if(ans<0)
			ans = ans + max;
		ans = (ans%max + (n - num*k)%max)%max;
		if(ans<0)
			ans = ans + max;
	}
	else if(wr >= num)
	{
		ans = (ans%max + ((k-1)*num)%max)%max;
		ans = (ans%max + (n - num*k)%max)%max;
		ans = (ans - (wr - num))%max;
	}
	if(ans < 0)
		ans = ans+max;
	printf("%lld\n", ans%max);
}


#include<stdio.h>
#define mod 1000000009
long long int power(long long int min)
{
	if(min==0)	return 1;
	if(min==1)	return 2;
	if(min%2)	return (((power(min/2))%mod)*(power((min+1)/2))%mod)%mod;
	else	return (((power(min/2))%mod)*((power(min/2))%mod))%mod;
}
int main()
{
	long long int n,m,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	long long int temp=m;
	long long int min=0;
	while(n)
	{
		if(n>m)
		{
			if(m>=k-1)
			{
				n=n-(k-1);
				m=m-(k-1);
			}
			n--;
		}
		else
		{
			min=n/k;
			break;
		}
	}
//	printf("%lld\n",min);
	long long int score;
	score=((power(min+1))%mod-2)%mod;
	score=(score*k)%mod;
//	printf("%lld\n",score);
//	printf("%lld\n",min);
	score = (score+temp-((min*k)%mod))%mod;
	score=(score+mod)%mod;
	printf("%lld\n",score);
	return 0;
}


#include<stdio.h>
#define MOD 1000000009

int sqr(long long int x, int n)
{
	if(n==0)
		return 1;
	else if(n==1)
		return x;
	else if(n%2==0)
		return sqr( (x*x)%MOD, n/2 ) % MOD;
	else
		return (x * sqr( (x*x)%MOD, (n-1)/2 )) % MOD;
}

int main()
{
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	int x, y, z;
	z = n%k;
	y = n/k;
	x = m - y*(k-1) - z;
	y -= x;
	long long int ans;
	int i;
	ans = sqr(2, x+1);
	ans -= 2;
	k %= MOD;
	ans *= k;
	ans %= MOD;
	ans += y*(k-1);
	ans %= MOD;
	ans += z;
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>
#define p 1000000009
long long int powe(long long int,long long int);
int main()
{
	long long int n,m,k,x,minscore;
	scanf("%lld %lld %lld",&n,&m,&k);
	x=m-((k-1)*(n/k)+n%k);
//	printf("%lld\n",x);
	minscore= (( ( powe(2,x+1)-2)*k)%p +m-x*k)%p;
//	printf("%lld\n",powe(2,x));
	printf("%lld\n",minscore);
}
long long int powe(long long int m,long long int n)
{
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return m;
	}
	if(n%2==0)
	{
		return(powe((m*m)%p,n/2)%p);
	}
	else
	{
		return((powe((m*m)%p,n/2)*m)%p);
	}
}


#include <stdio.h>
#include <stdlib.h>
#define NUM 1000000009

int minx(int n, int m, int k)
{
  int q = n/k;
  return m - q*(k-1) - n%k;

}

long long int power(int n, int m)
{
  if(m == 0)
    return 1;
  else
    {
      if(m % 2 == 0)
	return (power(n,m/2)*power(n,m/2)) % NUM;
      else
	return (power(n,m-1)*n) % NUM;
    }

}

long long int score(int x, int m, int k)
{
  return ((power(2,x+1)-2)*k + m -x*k) ;

}
int main()
{
  int n,m,k;
  scanf("%i %i %i",&n,&m,&k);
  int x = minx(n,m,k);
  long long int result = score(x,m,k);
  printf("%lli",result % NUM);

  return 0;
}


#include<stdio.h>
#define maxn 102

int max(int a, int b)
{
    int t;
    if(a<=b)
        t=b;
    else t=a;
    return t;
}

int main()
{
    int n, a[maxn], i, nodel=0, curstreak=1, longstreak=1, count=0;

    scanf("%d", &n);

    for(i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
    }
    if(1000-a[1]==n-1 || a[n]==n)
        nodel=n-1;
    else
    {
        for(i=1; i<=n; i++)
        {
            if(a[i+1]-(i+1)==a[i]-i)
            curstreak++;
            else
                {
                    longstreak = max(longstreak, curstreak);
                    curstreak = 1;
                }
            if(a[1]==1&&a[2]=!a[1]+1)
                nodel=max(longstreak, curstreak)-1;
            else
                nodel=max(longstreak, curstreak)-2;
        }
    }

    printf("%d", nodel);

    return 0;
}


#include<bits/stdc++.h>

int arr[1010];

int main() {
	int m, n, i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) scanf("%d", &arr[i]);
	int maxn = 0;
	int cur = 0;
	arr[0] = 0, arr[n + 1] = 1001;
	n++;
	cur = 1;
	for (i = 1; i <= n; i++) {
		if (arr[i] == arr[i - 1] + 1) cur++;
		else {
			cur = 1;
			continue;
		}
		if (maxn < cur) maxn = cur;
	}
	maxn -= 2;
	printf("%d\n", std::max(0, maxn));
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    double n;
    scanf("%lf"，&n);
    printf("%d",(int)sqrt(n));
     return 0;
}


#include <stdio.h>
#include <stdint.h>
int main(void) {
    int64_t n, m;
    scanf("%I64d%I64d", &n, &m);
    if(m > n) {
        printf("%I64d", n);
        return 0;
    }
    n -= m;
    for(int64_t l = 0, r = 2e9; l < r; (l + r) / 2 >= (l + r) * (l + r + 2) / 8 ? r = (l + r) / 2 : l = (l + r) / 2 + 1);
    printf("%I64d", l + m);
    return 0;
}


#include<stdio.h>
#include<algorithm>
#define MAX 2000000000
//1000000000000000000
using namespace std;

int main()
{
	long long N, M, i, st = 1, ed = MAX,k =0;
	scanf("%lld%lld", &N, &M);

	if (M > N) M = N;

	long long ans =0, X= (N-M)*2;

	for (;;) {
		if (st >= ed) break;
		i = (st + ed) / 2;

		if (i*i + i >= X) {
			ed = i;
			k = i;
		}
		else {
			st = i + 1;
		}
	}

	ans = M + k;

	printf("%lld\n", ans);

	return 0;
}


#include <stdio.h>
#include <stdint.h>
int main(void) {
    int64_t n, m;
    scanf("%I64d%I64d", &n, &m);
    if(m > n) {
        printf("%I64d", n);
        return 0;
    }
    n -= m;
    for(int64_t l = 0, r = 2e9; l < r; (l + r) / 2 >= (l + r) * (l + r + 2) / 8 : r = (l + r) / 2 : l = (l + r) / 2 + 1);
    printf("%I64d", l + m);
    return 0;
}


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

int main()
{
    long long a,b;
    while (~scanf ("%I64d%I64d",&a,&b)){
        long long sum = a;
        long long i;
        for (i=b;;i++){
            sum=(sum+=b)>a?a:sum;
            if ((sum-=i)<=0) break;
        }
        printf("%I64d\n",i);
    }
    return 0;
}


#include <stdio.h>
#ifdef TEST
#include <time.h>
#endif

int main() {
    long long n, m;
    scanf("%I64d %I64d", &n, &m);
    if (m >= n)
        goto LOL_KEK;
#ifdef TEST
    clock_t cl = clock();
#endif
    long long i = m + 1;
    n -= i;
    while (n > 0)
        n += (m - (++i));
    printf("%I64d\n", i);
#ifdef TEST
    printf("%lf\n", (double)(clock() - cl) / CLOCKS_PER_SEC);
#endif
    return 0;
LOL_KEK:
    printf("%I64d\n", n);
    return 0;
}


#include<stdio.h>
void quicksort(double number[],long long int first,long long int last,double a[],double c[]){
   long long int i, j, pivot;
   double temp;

   if(first<last){
      pivot=first;
      i=first;
      j=last;

      while(i<j){
         while(number[i]<=number[pivot]&&i<last)
            i++;
         while(number[j]>number[pivot])
            j--;
         if(i<j){
            temp=number[i];
            number[i]=number[j];
            number[j]=temp;
			temp=a[i];
            a[i]=a[j];
            a[j]=temp;
			temp=c[i];
            c[i]=c[j];
            c[j]=temp;
         }
      }

      temp=number[pivot];
      number[pivot]=number[j];
      number[j]=temp;
	  temp=a[pivot];
      a[pivot]=a[j];
      a[j]=temp;
	  temp=c[pivot];
      c[pivot]=c[j];
      c[j]=temp;
      quicksort(number,first,j-1,a,c);
      quicksort(number,j+1,last,a,c);

   }
}
double power(long long int a,long long int b){
	long long int i,p=1;
	for(i=0;i<b;i++)
		p=p*a;
	return p;
}
int main(){
	long long int n,i,l,s=0,min;
	scanf("%lld %lld",&n,&l);
	double c[n],a[n],d[n];
	for(i=0;i<n;i++){
		scanf("%lf",&c[i]);
		a[i]=power(2,i);
		d[i]=c[i]/a[i];
	}
	quicksort(d,0,n-1,a,c);
	min= (l/((long long int)a[0]) + 1)*((long long int)c[0]);
	for(i=0;l!=0;i++){
		if(min> s + (l/((long long int)a[i]) + 1)*((long long int)c[i]))
			min= s+(l/((long long int)a[i]) + 1)*((long long int)c[i]);
		s=s+(l/((long long int)a[i]))*((long long int)c[i]);
		l=l%((long long int)a[i]);
	}
	if(min>s)
		printf("%lld",s);
	else
		printf("%lld",min);

	return 0;
}


#include <stdio.h>

int main(int argc, char const *argv[]) {
	int n, L;
	scanf("%d %d", &n, &L);

	int costs[n + 1], c, last = 0;
	int i;

	scanf("\n%d", &c);
	last = (costs[0] = c) << 1;

	for(i = 1; i < n; i++) {
		scanf(" %d", &c);
		last = (costs[i] = c < last ? c : last) << 1;
	}
	costs[n] = last;

	last >>= 1;
	for(i = n - 2; i >= 0; i--) {
		if(costs[i] > last)
			costs[i] = last;
		else
			last = costs[i];
	}

	long long sum = 0;
	for(i = 0; L && i < n;) {
		if(L & 1)
			sum += costs[i];
		if(costs[++i] < sum)
			sum = costs[i];
		L >>= 1;
	}

	sum += (long long)costs[n] * L;

	printf("%lld\n", sum);

	return 0;
}