#include<stdio.h>
int main()
{
char a[105];
int i,l;
scanf("%s",a);
l=strlen(a);
for(i=0;a[i]!='h';i++);
i++;
while(a[i]!='e'&&i<l)
i++;
i++;
while(a[i]!='l'&&i<l)
i++;
i++;
while(a[i]!='l'&&i<l)
i++;
i++;
while(a[i]!='o'&&i<l)
i++;
if(i>l)
{printf("NO");exit(0);}
printf("YES");
return 0;
}


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

int main () {
	int i , size  , found= 0;
	char str[10];
	scanf("%s",str);
	size = strlen (str) -1 ;
	for(i=0;i<size;i++){
		if (str[i]=='h'){
	           while(str[i] !='e' && i <size) {
			    i++;
		          }

		   	if(str[i]=='e' ){
				while(str[i]!='l' && i <size ){
					i++;
				}
				if(str[i]=='l'){
					i++;
					while(str[i]!='l' && i <size){
						i++;
					}
					if(str[i]=='l'){
						while(str[i] !='o' && i <size){
							i++;
						}
						 if(str[i]=='o'){
						 	found= 1;
						 }
					}
				}
			}
		}
	}

	if (found ==1 ){
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0 ;
	}


#include <stdio.h>
#include <cstdio>
const int N=1e5+10;
long long int x, i, n, a = 1;
long long int k (long long int x, long long int p)
{
	long long int s = 1;
	while (p)
	{
		if (p % 2)
			s = s * x % N;
		p /= 2;
		x = x * x % N;
	}
    return s;
}
long long int d (long long int p)
{
	long long int m = n, sum = 0;
	while (m)
		sum += m /= p;
	return k(p, sum);
}
int main()
{
	scanf("%lld%lld", &x, &n);
	for (i = 2; i * i <= x; i++)
		if (x % i == 0)
		{
			a = a * d(i) % N;
			while (x % i == 0)
				x /= i;
		}
	if (x != 1)
		a = a * d(x) % N;
	printf("%lld", a);
}


#include <stdio.h>
const int N=1e5+10;
long long int x, i, n, a = 1;
long long int k (long long int x, long long int p)
{
	long long int s = 1;
	while (p)
	{
		if (p % 2)
			s = s * x % N;
		p /= 2;
		x = x * x % N;
	}
    return s;
}
long long int d (long long int p)
{
	long long int m = n, sum = 0;
	while (m)
		sum += m /= p;
	return k(p, sum);
}
int main()
{
	scanf("%lld%lld", &x, &n);
	for (i = 2; i * i <= x; i++)
		if (x % i == 0)
		{
			a = a * d(i) % N;
			while (x % i == 0)
				x /= i;
		}
	if (x != 1)
		a = a * d(x) % N;
	printf("%lld", a);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <limits.h>
typedef long long ll;

ll MAX = 100000000000;  //  1e11
ll MIN = -100000000000; // -1e11
ll MOD = 1000000007;

ll longlongmax = __LONG_LONG_MAX__;

ll maxormin(ll a, ll b, ll flag)
{
    return flag == 1 ? (a > b ? a : b) : (a < b ? a : b);
}

ll overflowcheck(ll a)
{
    if (a == 1)
    {
        return 0;
    }
    else
    {
        ll temp = a;
        ll power = 1;
        while (longlongmax / temp > a)
        {
            temp *= a;
            power++;
        }
        return power + 1; // Overflow occurs at this power.
    }
}

ll merge(ll A[], ll B[], ll left, ll mid, ll right)
{
    ll count = 0;
    ll n1 = mid - left + 1;
    ll n2 = right - mid;

    ll LA[n1], LB[n1], RA[n1], RB[n2];

    for (ll n = 0; n < n1; n++)
    {
        LA[n] = A[n + left];
        LB[n] = B[n + left];
    }
    for (ll n = 0; n < n2; n++)
    {
        RA[n] = A[n + mid + 1];
        RB[n] = B[n + mid + 1];
    }

    ll i = 0, j = 0, k = left;

    while (i < n1 && j < n2)
    {
        if (LA[i] < RA[j])
        {
            A[k] = LA[i];
            B[k] = LB[i];
            i++;
        }
        else
        {
            A[k] = RA[j];
            B[k] = RB[j];
            count += n1 - i;
            j++;
        }
        k++;
    }
    while (i < n1)
    {
        A[k] = LA[i];
        B[k] = LB[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        A[k] = RA[j];
        B[k] = RB[j];
        j++;
        k++;
    }
    return count;
}

ll mergesort(ll A[], ll B[], ll left, ll right)
{
    ll total = 0;
    if (left < right)
    {
        ll mid = (right - left) / 2 + left;
        total += mergesort(A, B, left, mid);
        total += mergesort(A, B, mid + 1, right);
        total += merge(A, B, left, mid, right);
    }
    return total;
}

ll primemarked[3000000];
ll primearray[3000000];
ll primeind;

void setupprimes()
{
    for (ll i = 2; i < 3000000; i++)
    {
        for (ll j = 2 * i; j < 3000000; j += i)
        {
            primemarked[j] = 1;
        }
    }
    for (ll i = 2; i < 3000000; i++)
    {
        if (!primemarked[i])
        {
            primearray[primeind++] = i;
        }
    }
}

ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result

    x = x % p; // Update x if it is more than or
               // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}

ll factorsX[3000000];
ll ind = 0;

int main(int argc, char const *argv[])
{
    ll T = 1;
    // scanf("%lld",&T);
    setupprimes();

    for (ll t = 0; t < T; t++)
    {
        ll x, N;
        scanf("%lld %lld", &x, &N);
        for (ll j = 0; j < primeind; j++)
        {
            if ((x % primearray[j]) == 0)
            {
                factorsX[ind++] = primearray[j];
            }
        }
        if (!ind)
        {
            // a prime itself
            factorsX[ind++] = x;
        }

        ll total = 1;
        // printf("%lldpopop\n",longlongmax/947);
        for (ll o = 0; o < ind; o++)
        {
            // for each prime factor calculate
            ll count[300];
            ll cind = 0;
            ll fac = factorsX[o];
            ll p = 1;
            ll gh = 1;
            while (p <= N && gh)
            {
                // printf("%lld\n",p);
                count[cind++] = N / p;
                if( p >= longlongmax/fac)
                {
                    gh = 0;
                }
                p *= fac;
            }

            for (ll m = 0; m < cind; m++)
            {
                ll num = 1;
                ll prod ;

                if(m!=(cind-1))
                {
                   num = (m*(count[m]-count[m+1]))%(MOD-1);
                }
                else
                {
                    num = (m*count[m])%(MOD-1);
                }
                // printf("%lld\n",num);
                prod = power(factorsX[o],num,MOD);
                total  = (total*prod)%MOD;
                total %= MOD;
            }
        }
        printf("%lld\n",total%MOD);
    }

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	char a[100100],c;
	int i,sum;
	int num[26],flag1,flag2,num1,sum1,k,h,total;
	while(scanf("%s",a)!=EOF)
	{
		sum=0;
		memset(num,0,sizeof(num));
		for(i=0;a[i];i++)
			if(a[i] != '0')
				break;
		if(a[i] ==0)
		{
			printf("1\n");
			continue;
		}
		flag1=0;
		flag2=0;
		num1=0;
		if(a[i] == '?')
			flag1=1;
		else if(a[i]>='A' && a[i] <='J')
		{
			flag2=1;
			c=a[i];
		}
		for(;a[i];i++)
		{
			if(a[i]>='A' && a[i]<='J')
			{
				if(num[a[i] -'A'] == 0)
					num1++;
				num[a[i] -'A']++;
			}
			else if(a[i] == '?')
				sum++;
		}
		if(flag1 == 1)
			total = sum *9;
		else
			total = sum*10;
		if(flag2 == 1)
		{
			h=2;
			sum1=9;
			k=9;
			for(;h<=num1;h++)
			{
				sum1*=k;
				k--;
			}
			total *= sum1;
		}
		else
		{
			sum1=1;
			k=10;
			for(h=1;h<=num1;h++)
			{
				sum1*=k;
				k--;
			}
			total *= sum1;
		}
		if(total ==0)
			printf();
		printf("%d\n",total);
	}
	return 0;
}


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

int max(int ent1, int ent2)
{
    if (ent1 > ent2)
        return ent1;

    return ent2;
}

int min(int ent1, int ent2)
{
    if (ent1 > ent2)
        return ent2;

    return ent1;
}

int mini = 100000;

void BF(int HPY, int ATKY, int DEFY, int HPM, int ATKM, int DEFM, int count)
{
    if ((HPY > 201) || (ATKY > 201) || (DEFY > 201))
        return;

    if (ATKY <= DEFM)
        return;

    while(HPM > 0 && HPY > 0)
    {
        HPY -= max(0,ATKM-DEFY);
        HPM -= max(0,ATKY-DEFM);
    }

    if (HPY > 0)
    {
        mini = min(count,mini);
        return;
    }
}

int main()
{
    int HPY,ATKY,DEFY;
    int HPM,ATKM,DEFM;
    int h,a,d;

    //sscanf("76 63 14 89 87 35 20 15 56", "%d %d %d %d %d %d %d %d %d", &HPY, &ATKY, &DEFY, &HPM, &ATKM, &DEFM, &h, &a, &d);

    scanf("%d %d %d", &HPY, &ATKY, &DEFY);
    scanf("%d %d %d", &HPM, &ATKM, &DEFM);
    scanf("%d %d %d", &h, &a, &d);

    int i,j,k;
    for (i = 0;i<=200;++i)
    {
        for (j = 0;j<=200;++j)
        {
            for (k = 0;k<=200;++k)
            {
                BF(HPY+i,ATKY+j,DEFY+k,HPM,ATKM,DEFM,i*h+j*a+k*d);
            }
        }
    }

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

    return 0;
}


#include <stdio.h>

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

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

int main()
{
    int HPY,ATKY,DEFY;
    int HPM,ATKM,DEFM;
    int addDEF = 0;
    int count = 0;
    int mini = 1000001;
    int h,a,d;

    scanf("%d %d %d", &HPY, &ATKY, &DEFY);
    scanf("%d %d %d", &HPM, &ATKM, &DEFM);
    scanf("%d %d %d", &h, &a, &d);

    int i;
    int HPYS = HPY,ATKYS = ATKY,DEFYS = DEFY;
    int HPMS = HPM,ATKMS = ATKM,DEFMS = DEFM;
    /* Increase attaque every time */
    for (i=0;i<100;++i)
    {
        count += a*i;

        while (HPM > 0)
        {
            if (HPY < (ATKM-DEFY))
            {
                while (max(0,ATKM-(DEFY+addDEF)) >= HPY)
                    ++addDEF;

                if ((max(0, ATKM-DEFY)-(HPY)+1)*h < addDEF*d)
                {
                    count += (max(0, ATKM-DEFY)-(HPY)+1)*h;
                    HPY += max(0, ATKM-DEFY)-(HPY)+1;
                    addDEF = 0;
                }
                else
                {
                    count += addDEF*d;
                    DEFY += addDEF;
                    addDEF = 0;
                }
            }

            HPM -= max(0, ATKY+i-DEFM);
            HPY -= max(0, ATKM-DEFY);
        }

        if (HPY > 0)
            mini = min(mini, count);

        HPY = HPYS,ATKY = ATKYS,DEFY = DEFYS;
        HPM = HPMS,ATKM = ATKMS,DEFM = DEFMS;

        count = 0;
    }

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

    return 0;
}


#include <stdio.h>

int main() {
	int x, y, r, a;
	scanf_s("%d",&r);
	r = r - 1;
	y = (r - 2) / 2;
	x = 0;
	while (++x) {
		if (x * (x + (2 * y) + 1) == r) {
			printf("%d %d", x, y);
			break;
		}
		else if (x * (x + (2 * y) + 1) > r) {
			puts("NO");
			break;
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
    long long int x,i;
    double y,b,r;
    scanf("%lf",&r);
    for(x=1;x<12;x=x+1)
    {
        y=(r-x*x-x-1)/(2*x);

        if((int)y == y&&y>0){
            printf("%lld %lld",x,(long long int)y);
            return 0;
        }
    }
    printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{
    int x,i;
    double y,b,r;
    scanf("%lf",&r);
    for(x=1;x<r;x=x+1)
    {
        y=(r-x*x-x-1)/(2*x);

        if((int)y == y&&y>0){
            printf("%d %d",x,(int)y);
            return 0;
        }
    }
    printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{
   long long int i,n,s=0,j=0;
    scanf("%lld",&n);
    for(i=1;i<n;i++)
    {

        for(j=1;j<n;j++){
        s=(i*i)+i+(2*i*j)+1;
            if(s==n)
            goto exit;
            }

    }

    exit:
        if(s==n)
    printf("%lld %lld",i,j);
    else
    printf("NO");
}


#include<stdio.h>
#include<algorithm>
#define MAXN 1000000000001
using namespace std;
int main()
{
	long long f=0,r,y;
	scanf("%lld",&r);
	for(long long i=1;i<r;i++)
	{
		if(i*i>=r)	break;
		if((r-i*i-i-1)%(2*i)==0)
		{
			y=(r-i*i-i-1)/(2*i),f=1;
			printf("%lld %lld",i,y);
		}
		if(f)	break;
	}
	if(!f)	printf("NO\n");

 }


#include<stdio.h>
int main(){
long long int r;
scanf("%lld",&r);
long long int x=1,y=1,f=0;

long long int j=x;
long long int k=y;
for(j=1;j<=r-1;j++)
{
    for(k=1;k<=r-1;k++)
    {
        if((j)*(j+(2*k)+1)==r-1)
        {
            f=1;
            break;
        }
    }
    if(f==1)
        break;
}
if(f)
printf("%lld %lld",j,k);
else printf("NO");
return 0;
}


#include<stdio.h>
int main(void)
{
long int r,x,y;
scanf("%ld",&r);
	y = ( r - 3 )/2;

if( r % 2 == 0 || y == 0 )
{
printf("NO\n");
}
else
{
x = 1;
printf("1 %ld",y);
}
return 0;
}


#include<stdio.h>
int main()
{   int a;
    scanf("%d",a);
    if(a%2)
    printf("No");
    else
    printf("Yes");
    return 0;
}


#include <stdio.h>

main(){
    int n;
    scanf("%d",&n);
    if(n%2==0)
    printf("YES");
    else
    printf("NO");

    return 1;
}


#include<stdio.h>

int main(){
	int r, x1, y1, x2, y2;
	int n;

	scanf("%d%d%d%d%d", &r, &x1, &y1, &x2, &y2);

	for (n = 0; n < 100000000000; n++){
		unsigned long temp1 = (unsigned long)(x2 - x1)*(unsigned long)(x2 - x1) + (unsigned long)(y2 - y1)*(unsigned long)(y2 - y1);
		unsigned long temp2 = (unsigned long)(4 * r*r*n*n);
		if ( temp1 <= temp2){
		printf("%d", n);
		return 0;
	}
	}
	return 0;
}


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

const int mod = (int)1e9 + 7;

long long choose(long long n, int k) {
  if (k > n) {
    return 0;
  }

  long long p = 1;
  for (long long i = n; i > n - k; i--) {
    p *= i;
    p %= mod;
  }

  return p;
}

int main(void) {
  int m;
  scanf("%i", &m);

  char s[50];
  sprintf(s, "%i", m);

  int len = strlen(s);
  long long f[len+1][len+1][2];

  memset(f, 0, sizeof(f));

  f[0][0][1] = 1;
  for (int i = 0; i < len; i++) {
    for (int j = 0; j <= len; j++) {
      for (int eq = 0; eq <= 1; eq++) {
        long long cur = f[i][j][eq];
        for (char d = '0'; d <= '9'; d++) {
          if (eq && d > s[i]) {
            continue;
          }
          int n_eq = eq && (d == s[i]);
          int is_lucky = (d == '4' || d == '7') ? 1 : 0;
          f[i+1][j+is_lucky][n_eq] += cur;
          f[i+1][j+is_lucky][n_eq] %= mod;
        }
      }
    }
  }

  long long counts[len+1];
  for (int i = 0; i <= len; i++) {
    counts[i] = f[len][i][0] + f[len][i][1];
    counts[i] %= mod;
  }
  counts[0] = (counts[0] + mod - 1) % mod;

  long long ans = 0;
  for (int i = 1; i <= len; i++) {
    long long tot = 0;
    for (int j = 0; j < i; j++) {
      tot += counts[j];
    }
    long long nways = counts[i] * choose(tot, 6) % mod;
    ans += nways;
    ans %= mod;
  }

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

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main(int argc,char** argv){
	int numberofcommand;
	char sourcecode[120];
	long long unsigned int result=0;
	long long unsigned int counter=0;
	//int skip[120];
	//int counterofskip=0;

	//skip[0]=-1;
	scanf("%d",&numberofcommand);
	scanf("%s",sourcecode);
	for(int i=0;i<numberofcommand;i++){
		/*if(i==skip[counter]){
			counter++;
			continue;
		}*/
		int numofR=0;
		int numofL=0;
		int numofU=0;
		int numofD=0;
		for(int j=i;j<numberofcommand;j++){

			switch(sourcecode[j]){
				case 'R': numofR++;break;
				case 'L': numofL++;break;
				case 'U': numofU++;break;
				case 'D': numofD++;break;
				default:break;
			}
			if(numofD==numofU&&numofL==numofR){
				result++;
				//skip[counterofskip++]=j+1;
			}
		}
	}
	printf("%I64d",result);
	return 0;
}


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

using namespace std;

int main(void)
{
    int k,i,j,conv,flag,q;
    scanf("%d",&k);
    int a[9]={0};
    flag=0;
    char str[5];
    for(i=0; i<4; i++)
    {
                  scanf("%s",str);
              //    printf("\n%s",str);
                  for(q=0; q<4; q++)
                  {
                  conv=str[q];
            //      printf("\n c=%c d=%d",str[q],conv);
                  switch(conv)
                  {
                            case 49 : a[0]++;
                                      break;
                            case 50 : a[1]++;
                                      break;
                            case 51 : a[2]++;
                                      break;
                            case 52 : a[3]++;
                                      break;
                            case 53 : a[4]++;
                                      break;
                            case 54 : a[5]++;
                                      break;
                            case 55 : a[6]++;
                                      break;
                            case 56 : a[7]++;
                                      break;
                            case 57 : a[8]++;
                                      break;
                            case 46 : break;
                  }
               //   }
             }
    }
    k*=2;
    for(i=0; i<9; i++)
    {
             if(a[i]>k)
             {
                 flag=1;
                 break;
             }
             if(flag==1)
                break;
    }
    if(flag==1)
        printf("NO");
    else
        printf("YES");
  //  getch();
    return 0;
}


#include<stdio.h>
int main(){
int bekci,n,x,y,z,i,j,dizi[4][4],arr[10];
scanf("%d",&x);
for(i=0 ; i<4 ; i++){
	for(j=0 ; j<4 ; j++){
		scanf("%d",&dizi[i][j]);
		if(dizi[i][j]=='.');
		else {
		arr[dizi[i][j]]++;}}}
for(i=1 ; i<10 ; i++){
	if(arr[i]<=2*x)
		bekci++;
	else if(arr[i]>2*x){
		printf("NO");
		break;}}
if(bekci==9)
	printf("YES");
return 0;}


#include<iostream.h>

int main(){
int i,j,k,n,ans=0,z;

scanf("%d",&n);
for(i=1;i<=n;i++){
    for(j=i;j<=n;j++){
        for(z=j;z<=n;z++)
                {

                  if(!(i^j^z))
                    ans+= i+j>z ;

               }

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


#include<stdio.h>
int main()
{
    int n,flag=0,midindex=0,i,j,temp,k;
    scanf("%d",&n);
    int a[1000];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        midindex=i;
        for(j=i+1;j<n;j++)
        {
            if(a[midindex]>a[j])
            midindex=j;
        }
        if(midindex!=i)
        {
            temp=a[midindex];
            a[midindex]=a[i];
            a[i]=temp;
        }
    }
   for(i=0;i<n;i++)
{
 for(j=i+1;j<n;)
 {
    if(a[i]==a[j])
    {

     for(k=j;k<size;k++)
     {
      a[k]=a[k+1];
     }
         n--;
        }
    else
    {
      j++;
     }
 }
}
    }
    for(i=0;i<=n-3;i++)
    {
        if(a[i]+1==a[i+1]&&a[i]+2==a[i+2])
        flag++;
    }
    if(flag>0)
    printf("YES");
    else
    printf("NO");
    return 0;
}


#include <stdio.h>

const int N = 50;

int n;
int arr[N];

int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++) scanf("%d",&arr[i]);
	for(register int i=1;i<=n;i++){
		for(register int j=1;j<=n;j++){
			for(register int k=1;k<=n;k++){
				if(arr[k]==arr[j]+1 && arr[j]==arr[i]+1){
					printf("YES\n");
					return 0;
				}
			}
		}
	}
	printf("NO\n");
	return 0;
}


#include<stdio.h>
int b[100000];
int i;
int tog;
int cmpfunc (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}

int main()
{
	int a;
	scanf("%d",&a);
	for(i=0;i<a;i++)
	{
		scanf("%d",&b[i]);
	}
	qsort(b,a,sizeof(int),cmpfunc);
	int count=1;
	for(i=1;i<a;i++)
	{
		if(b[i]-b[i-1]==1)
		{
			count++;
		}
		else
			count=1;
		if(count==3)
		{
			tog=1;
			break;
		}
	}
	if(tog==1)
	{
		printf("YES");
	}
	else
		printf("NO");
printf("\n")

	return 0;
}


#include<stdio.h>
int main() {
    int n;
    while(scanf("%d",&n))
    {
        int a[n];
    int i;
    for(i=0; i<n; i++) {
        scanf("%d",&a[i]);
    }
    int j;
    int swap;
    for (i = 0 ; i < ( n - 1 ); i++)
        {
        for (j = 0 ; j < n - i - 1; j++)
        {
            if (a[j] > a[j+1]) {
                  swap=a[j];
                a[j] = a[j+1];
                a[j+1]= swap;
            }
        }
    }
    int y=0;
    int x=1;
    int temp=a[0];
   for(i=1;i<n;i++)
   {
   if(a[i]==temp+1)
   {
       x++;
       temp=a[i];
   }
   else
   {
       temp=a[i];
   }
    if(x==3)
    {
        printf("YES\n");
        y=1;
        break;
    }

   }
   if(y==0)
    printf("NO\n");
    }

    return 0;
}


include<stdio.h>
int main()
{
int x,y,z,i,sum;
  scanf("%d%d%d",&x,&y,&z);
  printf("%d\n%d\n%d",x,y,z);
  for(i=x;i>=1;i--)
  {
    if(y>=2*i && z>=4*i)
    break;

  }
  sum=i+2*i+4*i;

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

}


#include<stdio.h>
int main()
{
	int a,b,c,i;
	scanf("%d%d%d",&a,&b,&c);
	for(i=a;i>=0;i--)
	{
		if(2*i<=b && 4*i<=c)
			break;
	}
	printf("%d\n",7*i);
	return 0;


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

int main()
{
    int a,b,c,x,y,z,r;
    scanf("%d %d %d",&a,&b,&c);
    if(c%4==0)
    {
        z=c;
    }
    else{r=c/4;z=r*4;}
    y=z/2;x=y/2;
    if(x<=a&&y<=b){
    printf("%d",x+y+z);
    }
    else{printf("0");1}
}


#include<stdio.h>
int main()
{
int a,b;
scanf("%d",&a);
if(a==0)
{
b=0
}
else if(a%2==0)
{
b=a+1;
}
else
{
b=(a+1)/2;
}
printf("%d",b);
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;
}


#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;
}


#include<stdio.h>
#include<time.h>
int t[40], n,m,tot,ans;
void dfs(int now,int cnt)
{
	if(cnt>=ans)
		return;
	while(now<tot&&t[now]>0)
		now++;
	if(now>=tot)
	{
		int i;
		for(i=0;i<tot;++i)
			if(!t[i])
				return;
		ans=cnt;
	}
	dfs(now+1,cnt);
	if(!t[now])
	{
		t[now]++;
		if(now-m>=0)	t[now-m]++;
		if(now%m>0)		t[now-1]++;
		if(now+m<tot)	t[now+m]++;
		if(now%m<m-1)	t[now+1]++;
		dfs(now+1,cnt+1);
		t[now]--;
		if(now-m>=0)	t[now-m]--;
		if(now%m>0)		t[now-1]--;
		if(now+m<tot)	t[now+m]--;
		if(now%m<m-1)	t[now+1]--;
	}
}
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	ans=tot=n*m;
	dfs(0,0);
	printf("%d",tot-ans);
	return clock();
}


#include<stdio.h>
#include<time.h>
int t[400],n,m,tot,ans;
void dfs(int now,int cnt)
{
	if(cnt>=ans)
		return;
	while(now<tot&&t[now]>0)
		now++;
	if(now>=tot)
	{
		int i;
		for(i=0;i<tot;++i)
			if(!t[i])
				return;
		ans=cnt;
	}
	if(cnt==ans)
		return;
	int to;
	cnt++;
	if(now>=m)
	{
		to=now-m;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
	if(now%m>0)
	{
		to=now-1;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
	if(now+m<tot)
	{
		to=now+m;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
	if(now%m<m-1)
	{
		to=now+1;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	ans=tot=n*m;
	dfs(0,0);
	printf("%d",tot-ans);
	return clock();
}


#include<stdio.h>
int t[400],n,m,tot,ans;
void dfs(int now,int cnt)
{
	if(cnt>=ans)
		return;
	while(now<tot&&t[now]>0)
		now++;
	if(now>=tot)
	{
		int i;
		for(i=0;i<tot;++i)
			if(!t[i])
				return;
		ans=cnt;
	}
	if(cnt==ans)
		return;
	int to;
	cnt++;
	if(now>=m)
	{
		to=now-m;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
	if(now%m>0)
	{
		to=now-1;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
	if(now+m<tot)
	{
		to=now+m;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
	if(now%m<m-1)
	{
		to=now+1;
		t[to]++;
		if(to-m>=0)	t[to-m]++;
		if(to%m>0)		t[to-1]++;
		if(to+m<tot)	t[to+m]++;
		if(to%m<m-1)	t[to+1]++;
		dfs(now+1,cnt);
		t[to]--;
		if(to-m>=0)	t[to-m]--;
		if(to%m>0)		t[to-1]--;
		if(to+m<tot)	t[to+m]--;
		if(to%m<m-1)	t[to+1]--;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	ans=tot=n*m;
	dfs(0,0);
	printf("%d",tot-ans);
	return 0;
}


#include<stdio.h>
int main()
{
    long int n,i,j,k,x;
    long long int count;
    scanf("%ld",&n);
    count=0;
    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j++)
        {
            for(k=j;k<=n;k++)
            {
                if((i+j)>k && (j+k)>i && (i+k)>j)
                {
                    x=i^j^k;
                    if(x==0)
                    {
                    count++;
                    }
                }
            }
        }
    }
    printf("%lld",count);
    return 0;
}


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

int main()
{
    int n ,a,b,c,counter=0;

    scanf("%d",&n);

    for(c=n;c>=1;c--)
    {
        for(b=c;b>=1;b--)
        {

            for(a=b;(a>=1)&&(a+b>c)&&(a+c>b);a--)
            {
                if(a^b^c)
                    continue;
                else if((b+c>a))
                {
                   //printf("%d %d %d\n",a,b,c);
                    counter++;
                }

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


#include<stdio.h>
int if_dif(int n,int i,int j)
{
	return n^i^j;
}
int if_get(int n)
{
	int max;
	int i,j;
	max=0;
	for(i=n;i>=1;i--)
	{
		for(j=1;j<=i;j++)
		{
			if(if_dif(j,i,n)==0&&j+i>n)
				max++;
		}
	}
	return max;
}
int main()
{
	int i;
	int n;
	int a[3000];
	scanf("%d",&n);
	a[0]=0;
	for(i=1;i<n;i++)
		a[i]=a[i-1]+if_get(i+1);
	printf("%d\n",a[n-1]);
	return 0;
}


#include <stdio.h>

int XOR( int a, int b, int c){
 	if( (a^(b^c)) == 0){
 		return 1;
 	}
 	else{
 	return 0;
 	}
}

int triangle(int a, int b, int c){
	if( (a+b>c) && (b+c>a) && (a+c>b)){
		return 1;
	}

	else{
		return 0;
	}
}

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

  int counter=0;

  for(int i=1; i<=n; i++){
  	for(int j=1; j<=n; j++){
  		for(int k=1 ; k<=n ; k++){
  			if( XOR(i,j,k) == 1 && triangle(i,j,k)==1 ) {counter++;}

  		}

  	}

  }

  printf("%d" ,(counter/6));

	return 0;
}


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

int main(int argc,char* argv[])
{
    int x,y,z,temp,cpt=0,n;
    do{
        scanf("%d",&n);
    }while(n<1 && n>2500);
    for(z=1;z<=n;z++)
    {
        for(y=1;y<z;y++)
        {
            for(x=1;x<y;x++)
            {
                temp = x^y;
                if(temp == z && (x+y>z || x+y<z)) {
                    cpt++;
                }
            }
        }
    }
    printf("%d",cpt);
    return 0;
}


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

int compara(const void *p, const void *q);

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

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

	qsort(v, n, sizeof(int), &compara);
	int bandera=0;
	for(int l=0; l<(n-2); l++){
		for(int j=(l+1); j<(n-1);j++ ){
			for( int k=(j+1); k<n; k++){

				int dif1, dif2;
				dif1=v[j]-v[l];
				dif2=v[k]-v[j];

				if(dif1==1 & dif2==1){
					printf("YES");
					bandera=1;
					l=n-2;
					j=n-1;
					k=n;
				}
			}
		}
	}
	if(bandera==0){
	 	printf("NO");
	}

	return 1;
}

int compara(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    if (x < y){
        return -1;  // -1 para ascendente;
    }
}


#include<stdio.h>
int main()
{
    long long a, b, c=1, d=1, i, j,max,min;
    scanf("%lld %lld", &a, &b);
    for (i=1; i <=a; i++){
        c=c*i;
    }
    for (j=1; j<= b; j++){
        d=d*j;
    }
    if ( c==d){
        printf("%lld\n", d);
    }
    else{
        if (c>d){
            max=c;
            min=d;
        }
        else{
            max=d;
            min=c;
        }
    }
    while (1==1){
    if (max%min==0){
        printf("%lld\n", min);
        break;
    }
    else{
        max=min;
        min= max%min;
    }
    }
    return 0;
}


#include <stdio.h>

int fatorial(int x) {
	if(x == 0) {
		return 1;
	}
	return x * fatorial(x-1);
}

int euclides(int a, int b) {
    int r;

    do {
        r = a % b;
        a = b;
        b = r;
    } while (r != 0);

    return a;
}

int main() {
	int a, b;

	scanf("%d%d", &a, &b);
	a = fatorial(a);
	b = fatorial(b);
	printf("%d", euclides(a, b));

	return 0;
}
/* 1512825412620 */


#include <stdio.h>

int fact(int a){

    int x = 1;
    for (int i = 1; i <= a; i++){
        x *= i;
    }
    return x;
}
int mdc(int a, int b){

    int resto = a%b;

    if (!resto) return b;

    else return mdc(b, resto);
}

int main(){
    int a, b;

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

    printf("%d", mdc(fact(a),fact(b)));
}

/* 1504285883337 */


#include <stdio.h>
int main()
{
    int A,B,c,d=1,i,j,s=1,x,gcd;
    scanf("%d %d",&A, &B);
    for(i=1;i<=A;i++) {
        s=s*i;

    }
                for(j=1;j<=B;j++) {
            d=d*j;
            if(s>d) {
                x=s;
            }
            else {
                x=d;
        }
        for(;x>=1;x--) {
            if(s%x==0 && d%x==0) {
                gcd=x;
                break;
            }
        }
    }

    printf("%d",gcd);

    return 0;

}


#include<cstdio>
int main()
{
    int a, b, i, c=1;
    scanf("%d %d", &a, &b);
    for(i=a>b?b:a;i>0;i--)
    {
        c*=i;
    }
    printf("%d",c);
}


#include<stdio.h>
int main(){
    int n, k, l, c_, d, p, nl, np;
    scanf("%d %d %d %d %d %d %d %d",n, k, l, c_, d, p, nl, np);
    int ttl_drink=k*l;
    int ttl_lime=c_*d;
    int ttl_salt=p;

    int tst_drink = ttl_drink/nl;
    int tst_lime = ttl_lime;
    int tst_salt = p/np;

    int min;
    int a=tst_drink;
    int b=tst_lime;
    int c=tst_salt;

       if( (a<b) && (a<c) )
   {
      min = a;
   }
   else if(b<c)
   {
      min = b;
   }
   else
   {
      min = c;
   }
   printf("%d",min/3);
    return 0;
}


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

    return 0;
}


#include <stdio.h>
#include <stddef.h>

static void decrease_duplicates (int arr[], size_t sz);
static size_t sum_positive (int arr[], size_t sz);

int main (void) {
	size_t letter_count;
	scanf("%llu", &letter_count);

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

	//~ int max_letter_freq[] = {
		//~ 2, 5, 5
	//~ };
	//~ size_t letter_count = 3;

	for (size_t i = 0; i < letter_count; ++i) {
		decrease_duplicates(max_letter_freq + i, letter_count - i);
	}

	printf("%llu\n", sum_positive(max_letter_freq, letter_count));

	return 0;
}

static void decrease_duplicates (int arr[], size_t sz) {
	if (sz == 1)
		return;

	int elem = arr[0];
	int decrease_by = 1;
	for (size_t i = 1; i < sz; ++i) {
		if (arr[i] == elem) {
			arr[i] -= decrease_by;
			decrease_by++;
		}
	}
}

static size_t sum_positive (int arr[], size_t sz) {
	size_t sum = 0;
	for (size_t i = 0; i < sz; ++i)
		if (arr[i] > 0)
			sum += arr[i];

	return sum;
}


#include <stdio.h>
#include<string.h>
int main(void)
{
	char a[30],t;
	int i,k,alen,max,s;
	scanf("%s",a);
	scanf("%d",&k);
	alen=strlen(a);
	while(k>0)
	{
		for(i=0;i<alen-1;i++)
		{
				max=i;
				s=k;
				while(s>0)
				{
					if(a[i+s]>a[i])
						max=a[max]>a[i+s]?max:i+s;
					s--;
				}
				if(a[max]>a[i])
				{
					t=a[max];
					k=k-max+i;
					while(max-i>0)
					{
						a[max]=a[max-1];
						max--;
					}
					a[i]=t;
					break;
				}
		}
	}
	printf("%s",a);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main() {
    char a[20];
    int k;
    scanf("%s%d",a,&k);
    //就一个原则，把最大的放在最前面
    //把k步内最大的换到最前面
    int swaps=k;
    int na=strlen(a);
    int start=0;
    while(1){
        int i;
        int max=start;
        for(i=start+1;i<na && i<=start+swaps;i++){
            if(a[i]>a[max]){
                max=i;
            }
        }
        //printf("start=%d, max=%d\n",start,max);
        //printf("%s\n",a);
        int tmp=a[max];
        for(i=max;i>start;i--){
            a[i]=a[i-1];
        }
        a[start]=tmp;
        //printf("%s\n",a);
        swaps-=(max-i);
        if(swaps==0)break;
        start++;
        if(start==na-1)break;
    }
    printf("%s\n",a);
	return 0;
}


#include<iostream>
main()
{
      char a[20];
      int k,i,j,l,bar,temp,flag,var;
      scanf("%s",a);
      scanf("%d",&k);
      l=strlen(a);
      for(i=0;i<l;i++)
      a[i]=a[i]-'0';
      for(j=0;j<l;j++)
      {
        flag=0;
        for(i=j+1;i<j+1+(l>=k?k:l);i++)
         {
           if(a[i]>a[j])
          {
            var=i;
            flag=1;
          }
        }

        if(flag)
        {
          temp=a[var];
          for(bar=var-1;bar>=j;bar--)
          a[bar+1]=a[bar];
          a[j]=temp;
          k-=(var-j);
        }
      }
      for(i=0;i<l;i++)
      printf("%d",a[i]);
      printf("\n");
      scanf("%d",&j);
      return 0;
}


#include <stdio.h>
#include <string.h>
#define min2(x,y) (x<y?x:y)

int p[30];

void f(int num, int len)
{
	int i, k = 1, sum = p[1];

	if (len == 1)
	{
		printf("%d", p[1]);
		return;
	}

	for (i = 1; i <= min2(num + 1, len); i++)
	{
		if (sum < p[i]) sum = p[i], k = i;
	}
	p[k] = p[1];
	for (i = 1; i <= len - 1; i++) p[i] = p[i + 1];
	printf("%d", sum);
	f(num - k + 1, len - 1);
}
int main()
{
	int i, n, m;
	char in[30];

	scanf("%s %d", &in[1], &m);
	n = strlen(&in[1]);
	for (i = 1; i <= n; i++) p[i] = in[i] - '0';

	f(m, n);

	return 0;
}


0 1 2 3 4
aja evans

#include<stdio.h>
#include<string.h>
char a[32];
int l,b[32],st,m,swp;
int swap(int x,int y)
{
char ch;
int i;
if(y>x)
{
    ch=a[y];
    for(i=y;i>x;i--)
    {
        a[i]=a[i-1];
    }
    a[i]=ch;
}
return 0;
}
main()
{
int i,j,k;
scanf("%s %d",a,&k);
swp=k;
l=strlen(a);
st=0;
while(st<l-1)
{
    m=a[st];
    j=0;
    for(i=st+1;i<l;i++)
    {
        if(a[i]>m)
        {
            m=a[i];
            b[j]=i;
            j++;
        }
    }
    for(i=j-1;i>=0;i--)
    {
        if(swp>=b[i]-st)
        {
            swap(st,b[i]);
            swp=swp-(b[i]-st);
            break;
        }
    }
    st++;
}
for(i=0;i<l;i++)
{
printf("%c",a[i]);
}
return 0;
}


#include <stdio.h>
#include <strings.h>
main()
{
char s[20];
long long int i,j,k,m,temp=-1,ind,swap=0;
scanf("%s %I64d",s,&k);

for(i=0;i<strlen(s);i++)
{ temp=-1;
for(m=i+1;m<i+k+1;m++)
{
j=s[m]-'0';
if(j>s[i]-'0' && j>temp)
{
temp=j;
ind=m;

}

}
if(temp!=-1)
{
while(ind>i)
{
	if(swap==k)
	break;
s[ind]=s[ind-1];
s[ind-1]=temp+'0';
swap++;

ind--;
}

if(swap==k)
	break;

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

}


//KRV Template
#include<stdio.h>
#include<string.h>
#include<math.h>
void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
//BTW l,r are indices
void bubblesort(int arr[] , int l , int r)
{
    int i,j,temp=0;
    for(int i = l ; i<=r ; i++)
    {
    	for(int j = l ; j<r-temp ; j++)
    	{
    		if(arr[j]>arr[j+1])
    		{
    			swap(&arr[j],&arr[j+1]);
    		}
    	}
    	temp++;
    }
}
void rbubblesort(int arr[] , int l , int r)
{
    int i,j,temp=0;
    for(int i = l ; i<=r ; i++)
    {
    	for(int j = l ; j<r-temp ; j++)
    	{
    		if(arr[j]<arr[j+1])
    		{
    			swap(&arr[j],&arr[j+1]);
    		}
    	}
    	temp++;
    }
}
int maxinarray(int arr[] , int l , int r)
{
	int ans = arr[0];
	for(int i = l ; i<r ; i++)
	{
        if(arr[i+1]>=arr[i])
        {
        	ans = arr[i+1];
        }
	}
	return ans;
}
int mininarray(int arr[] , int l , int r)
{
	int ans = arr[0];
	for(int i = l ; i<r ; i++)
	{
		if(arr[i+1]<=arr[i])
		{
			ans = arr[i+1];
		}
	}
	return ans;
}
int main()
{
	//The actual part is here!!
    int n ;
    scanf("%d\n",&n);
    int tl = 0;
    if(n==1)
    {
        printf("1");
        return 0;
    }
    if(n==2)
    {
        printf("2");
        return 0;
    }
    if(n%2==1)
    {
        printf("%d",pow((n/2) + 1,2));
        return 0;
    }
    else
    {
        printf("%d",(n/2)*((n/2)+1));
        return 0;
    }
}


#include<stdio.h>
#include<string.h>
int main()
{
	int i,N;
	scanf("%d",&N);
	printf("%d\n",(N-1)*2);
	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    int i,a,sum;
    while(~scanf("%d",&a))
    {
        sum=1;
        a-=2;
        while(a-->=1)
            sum++;
        sum*=2;\
        printf("%d\n",sum);
    }
}


#include<stdio.h>
int main()
{
        int lemons,friends,salt,nsalt,ndrink,nlemons,bottles,ltrs,a,nltrs;
        scanf("%d",friends);
        scanf("%d",bottles);
        scanf("%d",ltrs);
        scanf("%d",lemons);
        scanf("%d",nlemons);
        scanf("%d",salt);
        scanf("%d",nltrs);
        scanf("%d",nsalt);
        ltrs=(ltrs*bottles)/nltrs;
        lemons=nlemons*lemons;
        salt=salt/nsalt;
        if(salt<ltrs&&salt<lemons)
        {
                a=salt;
        }
        else if(lemons<ltrs)
        {
                a=ltrs;
        }
        else
        {
                a=lemons;
        }
        printf("%d",a/friends);
}


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


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

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x, z, res, idx;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = 360 - x;

        res = 1LL << 60;
        for (i = 0; i <= 10000; i++){
            c = fucks(360 - x);
            d = fucks(180 - x);
            z = min(c, d);
            if (z < res) res = z, idx = i;
            x = (x + 90) % 360;
        }

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


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

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

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = -x;
        if (x < 0) x += 360;

        long long res = 0, min = 1010;
        for (i = 0; i <= 100; i++){
            d = (i * 90) % 360;
            c = fucks(d - x);
            if (c < min) min = c, res = i;
        }

        if ((y % 360) == 0) __builtin_trap();
        printf("%lld\n", res);
    }
    return 0;
}


#include<stdio.h>
int main(){
int w;
scanf("%d",w);
if (w%2==0){
printf("yes");}
else{
printf("no");}
return 0;}


#include <stdio.h>

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

	long long int n,i,j,k=1,l=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
	    k=k*2;
	    l=l+k;
	}
	printf("%I64d",l);
	return 0;
}


#include<stdio.h>
int main()
{
     long long int pdt=1,ans;
     int n,i,;
     scanf("%d",&n);

     for(i=0;i<=n;i++)
     p*=2;
     ans=p-2;
     printf("%l64d",ans);
     return 0;
}


#include<stdio.h>
int main()
{
	long long int n,j,ans=1,finalans=0;
	scanf("%d",&n);
	long long int i=1;
	while (i<=n)
	{
		for (j=1;j<=i;j++)
		{
			ans=ans*2;
		};
		finalans=finalans+ans;
		ans=1;
		i++;
	 }
	printf("%lld",finalans);
	return 0;
}


#include <stdio.h>
int main(void){
    int n, x, flag = 1;
    scanf("%d", &n);
    if (n & 1 == 0) {
        flag = 0;
    }
    for (inti = 0; i < x; i++){
        scanf("%d", &x);
        if ((i == 0 || i == x-1) && (x & 1 == 0)) {
            flag = 0;
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main(){
	int i,n;
	scanf("%d",&n);
	int count=0,a[n],j=0;
	for(i=0;i<n;i++){
		int v;
		scanf("%d",&v);
		count++;
		if(v%2==0){
			a[j++]=count;
		}
	}

	if(j==0){
		for(i=1;i<count;i++){
			int total=count%i+count/i;
			if(total%2!=0){
				printf("YES");
				return;
			}
		}
		printf("NO");
		return 0;
	}
	if(a[0]==1||a[j-1]==count||a[j-1]==count-1){
		printf("NO\n");
		return 0;
	}
	int t=0;

	for(i=0;i<j;i++){
		if(a[i+1]-a[i]==1&&i<=j-2){

			continue;

		}
		else if(a[i+1]-a[i]!=1&&i<=j-2){
				printf("kelaaa\n");
			if(a[i]<count-2){
				if((a[i]+1-t)%2==0){
					printf("NO");
					return 0;
				}
				else{
					t=a[i];
				}
			}
			else{
				if((count-t)%2==0){
					printf("NO");
					return 0;
				}
			}
		}
	}

	printf("YES");
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;

int main()
{
    int n,i,j;
    int a[10000];
    while(scanf("%d",&n)==1)
    {
        for(i=0; i<n; i++)
        {
            scanf("%d",a+i);
        }
        if(a[0]%2==0||a[n-1]%2==0)
        {
            printf("No\n");
            continue;
        }
        j=1;
        int cnt=0;
        for(i=0; i<n; i++)
        {
            if(a[i]%2==0)
                j++;
            else if(i<n-1&&a[i+1]%2==0)
                j++;
            else
            {
                if(j&1)
                {
                    j=1;
                    cnt++;
                }
                else
                    j++;
            }
        }
        if(j!=1||cnt%2==0)
            printf("No\n");
        else
            printf("Yes\n");
    }

    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,i,s[100];
    cin>>n;
    for(i=0;i<n;i++)

    {
        cin>>s[i];}
        if(n%2 &&s[0]%2 && s[n-1]%2)
        cout<<"yes";
    else
        cout<<"no";
    return 0;
}


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


#include<stdio.h>
int main()
{
    unsigned long long n,c=0;
    scanf("%llu",&n);
    while(n!=1)
    {
        if(n%2!=0){n=(n/2)+1;c++;}
        else {n=n/2;c++;}
    }
    printf("%llu",c);
}


#include<stdio.h>
int main(){
	long long int n,i=0;
	scanf("%lld",&n);
	long long int f[n+1];
	f[0] =1;
	f[1] =2;
	f[2] = 3;
	for (int k = 3; k < n+2; k++)
	{
		f[k] =2 ;
	}
	i=2;
	if(n>2){
		while(f[i]<=n){
			for (int j = 0; j < i ; j++)
			{
				f[i+1] = f[i+1] + f[j] ;
			}
			i++;
		}
	}
	if (n==2)
	{
		printf("1");
		return 0;
	}
	else {
		printf("%lld\n", i-1);
	}
	return 0;
}


#include<stdio.h>
int main(){
	long long int n,i=0;
	scanf("%lld",&n);
	if(n<1000) long long int f[n];
	else long long int f[n/10];
	f[0] =1;
	f[1] =2;
	f[2] = 3;
	for (int k = 3; k < n+2; k++)
	{
		f[k] =2 ;
	}
	i=2;
	if(n>2){
		while(f[i]<=n){
			for (int j = 0; j < i ; j++)
			{
				f[i+1] = f[i+1] + f[j] ;
			}
			i++;
		}
	}
	if (n==2)
	{
		printf("1");
		return 0;
	}
	else {
		printf("%lld\n", i-1);
	}
	return 0;
}


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

const int N = 505, MOD = 1000000007;

int f[2][505][505];

int poww[505];

int main() {
    int n, k,j,i,last;
    scanf("%d%d", &n, &k);
    poww[0] = 1;
    for (i = 1; i <= 500; ++i) {
        poww[i] = poww[i - 1] * 2 % MOD;
    }
    int now = 1;
    f[1][0][0] = 1;
    for (i = 1; i <= n; ++i) {
        int next = now ^ 1;
        for (j = 0; j < i && j <= k; ++j) {
            for (k = 0; k < i; ++k) {
                (f[next][j + 1][i] += (long long)(poww[i - k] - 1) * poww[k] % MOD * f[now][j][k] % MOD);f[next][j+1][i] %= MOD;
                (f[next][j][k] += (long long)poww[k] * f[now][j][k] % MOD);f[next][j][k] %= MOD;
                f[now][j][k] = 0;
            }
        }
        now = next;
    }
    int ans = 0;
    for (last = 0; last <= n; ++last) {
        (ans += f[now][k][last]);ans %= MOD;
    }
    printf("%d\n", ans);
    return 0;
}


#include<stdio.h>

int main()
{
	int n, m, num, min3, min1 = 10, min2 = 10, flag = 0;

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

	int temp[10];

	for(int i = 0; i < n; i++){
		scanf("%d", &num);
		++temp[num - 1];
		if(num < min1){
			min1 = num;
		}
	}
	for(int i = 0; i < m; i++){
		scanf("%d", &num);
		++temp[num - 1];
		if(num < min2){
			min2 = num;
		}
	}

	for(int i = 0; i < 10; i++){
		if(temp[i] > 0){
			if(temp[i] == 2){
				flag = 1;
				min3 = i + 1;
			}
		}
	}

	if(min1 < min2 && flag = 0){
		printf("%d%d\n", min1, min2);
	}else if(min1 > min2 && flag == 0){
		printf("%d%d\n", min2, min1);
	}else if(min1 == min2){
		printf("%d\n", min1);
	}else if(min1 < min2 && flag == 1 || min1 > min2 && flag == 1){
		printf("%d\n", min3);
	}
}


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


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

int main()
{
    int n,x,y;
    char ch;
    scanf("%d%c",&n,&ch);
    x=n;
    if(n%2!=0)
        x=x+1;
    x=x/2;
    if(x%2!=0)
        x++;
    x=x/2;
    y=16*(x-1);
    if(n%2==0)
        y=y+7;
    if(ch=='f')
        y=y+1;
    else if(ch=='e')
        y=y+2;
    else if(ch=='d')
        y=y+3;
    else if(ch=='a')
        y=y+4;
    else if(ch=='b')
        y=y+5;
    else if(ch=='c')
        y=y+6;
    printf("%d",y);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int i;
    char s[102],h[6],k=0;
    scanf("%s",s);
    for(i=0;i<strlen(s);)
    {
        if(s[i]==s[i+1])
        {
            i=i+2;
        }
        else
        {
            h[k]=s[i];
            k++;
            i++;
        }
    }
    if(strcmp(s,'hello'))
        printf("YES\n");
    else
        printf("N0\n");
    return 0;
}


/* practice with Dukkha */
#include <stdio.h>

int count(long long n) {
	return n == 0 ? 0 : count(n & n - 1) + 1;
}

int main() {
	long long s, x;

	scanf("%lld%lld", &s, &x);
	if (s < x || (s - x) % 2 != 0)
		printf("0\n");
	else
		printf("%lld\n", (1LL << count(x)) - (s == x ? 2 : 0));
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
long ms[2000000];
void print(LL *a,long size) {long i;for (i=1;i<size;i++) {printf("%lld ",a[i]);}printf("%lld\n",a[i]);}
void mergesort(LL*ds,long size)
{
	long i,j,k,s,b,e;
	for (k=1;k<=size;k=k<<1)
	{
		for (i=1;i+k<=size;i+=k<<1)
		{
			s=i;b=i+k;e=b+k-1;
			if (e>size) {e=size;}
			for (j=1;(s<i+k)&&(b<=e);j++)
			{
				if (ds[s]<=ds[b])
				{
					ms[j]=ds[s++];
				}
				else
				{
					ms[j]=ds[b++];
				}
			}
			for (b=i+k-1;b>=s;b--)
			{
				ds[e--]=ds[b];
			}
			for (b=1;b<j;b++)
			{
				ds[i+b-1]=ms[b];
			}
		}
	}
}
long gray(long a)
{
	return ((a<<1)^a)>>1;
}
inline uLL bsf64(uLL a)
{
	asm("bsfl %0,%0":"+r"(a));
	return a;
}
inline uLL bsr64(uLL a)
{
	asm("bsrl %0,%0":"+r"(a));
	return a;
}
inline LL max(LL a,LL b) {if (b>a) {a=b;}return a;}
inline LL min(LL a,LL b) {if (a>b) {a=b;}return a;}
LL ans1[1000000],ans2[1000000];
long num[1000],num2[1000];
int main()
{
//	freopen("in.in","r",stdin);
	long i,j,k,a,b,c,l,p,q,baka,r,m,n,mid;
	scanf("%ld %ld\n",&n,&m);
//	printf("%ld %ld\n",n,m);
	for (i=1;i<=n;i++)
	{
		scanf("%ld",&num[i]);
	}
	if (n>10) {q=n>>1;} {q=n;}
	*ans1=(LL)1<<q;ans1[1]=0;
	for (i=1;i<=q;i++) {num2[i]=num[i];}
	for (i=1;i<=*ans1;i++)
	{
		a=gray(i);b=gray(i-1);
		k=a^b;
		if (a&k) {ans1[i]=ans1[i-1]+num2[bsr64(k)];}
		if (b&k) {ans1[i]=ans1[i-1]+m-num2[bsr64(k)];}
		ans1[i]=ans1[i]%m;
	}
//	print(ans1,*ans1);
	//////////////////
	q=n-q;
	for (i=1;i<=q;i++) {num2[i]=num[n-i+1];}
	*ans2=(LL)1<<q;ans2[1]=0;
	for (i=1;i<=*ans2;i++)
	{
		a=gray(i);b=gray(i-1);
		k=a^b;
		if (a&k) {ans2[i]=ans2[i-1]+num2[bsr64(k)];}
			if (b&k) {ans2[i]=ans2[i-1]+m-num2[bsr64(k)];}
		ans2[i]=ans2[i]%m;
	}
	mergesort(ans1,*ans1);
	baka=0;
	for (i=1;i<=*ans2;i++)
	{
		l=1;r=*ans1;a=m-1-ans2[i];
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (ans1[mid]<a)
			{
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		if (l<=*ans1) {b=(ans2[i]+ans1[l])%m;baka=max(b,baka);}
		if (r>0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}
		l=1;r=*ans1;a=2*m-1-ans2[i];
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (ans1[mid]<a)
			{
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		if (l<=*ans1) {b=(ans2[i]+ans1[l])%m;baka=max(b,baka);}
		if (r>0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}
	}
	printf("%lld\n",baka);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
long ms[2000000];
void print(LL *a,long size) {long i;for (i=1;i<size;i++) {printf("%lld ",a[i]);}printf("%lld\n",a[i]);}
void mergesort(LL*ds,long size)
{
	long i,j,k,s,b,e;
	for (k=1;k<=size;k=k<<1)
	{
		for (i=1;i+k<=size;i+=k<<1)
		{
			s=i;b=i+k;e=b+k-1;
			if (e>size) {e=size;}
			for (j=1;(s<i+k)&&(b<=e);j++)
			{
				if (ds[s]<=ds[b])
				{
					ms[j]=ds[s++];
				}
				else
				{
					ms[j]=ds[b++];
				}
			}
			for (b=i+k-1;b>=s;b--)
			{
				ds[e--]=ds[b];
			}
			for (b=1;b<j;b++)
			{
				ds[i+b-1]=ms[b];
			}
		}
	}
}
long gray(long a)
{
	return ((a<<1)^a)>>1;
}
inline int bsf64(int a)
{
	__asm__("bsfl %0,%0":"+r"(a));
	return a;
}
inline int bsr64(int a)
{
	__asm__("bsrl %0,%0":"+r"(a));
	return a;
}
inline LL max(LL a,LL b) {if (b>a) {a=b;}return a;}
inline LL min(LL a,LL b) {if (a>b) {a=b;}return a;}
LL ans1[1000000],ans2[1000000];
long num[1000],num2[1000];
int main()
{
//	freopen("in.in","r",stdin);
	long i,j,k,a,b,c,l,p,q,r,m,n,mid;
	LL baka;
	scanf("%ld %ld\n",&n,&m);
//	printf("%ld %ld\n",n,m);
	for (i=1;i<=n;i++)
	{
		scanf("%ld",&num[i]);
		num[i]=num[i]%m;
	}
	if (n>10) {q=n>>1;} {q=n;}
	*ans1=(LL)1<<q;ans1[1]=0;
	for (i=1;i<=q;i++) {num2[i]=num[i];}
	for (i=1;i<*ans1;i++)
	{
		a=gray(i);b=gray(i-1);
		k=a^b;
		if (a&k) {ans1[i+1]=ans1[i]+num2[bsr64(k)];}
		if (b&k) {ans1[i+1]=ans1[i]+m-num2[bsr64(k)];}
		ans1[i+1]=ans1[i+1]%m;
	}
//	print(ans1,*ans1);
	//////////////////
	q=n-q;
	for (i=1;i<=q;i++) {num2[i]=num[n-i+1];}
	*ans2=(LL)1<<q;ans2[1]=0;
	for (i=1;i<*ans2;i++)
	{
		a=gray(i);b=gray(i-1);
		k=a^b;
		if (a&k) {ans2[i+1]=ans2[i]+num2[bsr64(k)];}
			if (b&k) {ans2[i+1]=ans2[i]+m-num2[bsr64(k)];}
		ans2[i+1]=ans2[i+1]%m;
	}
//	print(ans2,*ans2);
	mergesort(ans1,*ans1);
	baka=0;
	for (i=1;i<=*ans2;i++)
	{
		l=1;r=*ans1;a=m-1-ans2[i];
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (ans1[mid]<a)
			{
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		if (l<=*ans1) {b=(ans2[i]+ans1[l])%m;baka=max(b,baka);}
		if (r>0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}
		l=1;r=*ans1;a=2*m-1-ans2[i];
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (ans1[mid]<a)
			{
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		if (l<=*ans1) {b=(ans2[i]+ans1[l])%m;baka=max(b,baka);}
		if (r>0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}
	}
	printf("%lld\n",baka);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
long ms[2000000];
void print(LL *a,long size) {long i;for (i=1;i<size;i++) {printf("%lld ",a[i]);}printf("%lld\n",a[i]);}
void mergesort(LL*ds,long size)
{
	long i,j,k,s,b,e;
	for (k=1;k<=size;k=k<<1)
	{
		for (i=1;i+k<=size;i+=k<<1)
		{
			s=i;b=i+k;e=b+k-1;
			if (e>size) {e=size;}
			for (j=1;(s<i+k)&&(b<=e);j++)
			{
				if (ds[s]<=ds[b])
				{
					ms[j]=ds[s++];
				}
				else
				{
					ms[j]=ds[b++];
				}
			}
			for (b=i+k-1;b>=s;b--)
			{
				ds[e--]=ds[b];
			}
			for (b=1;b<j;b++)
			{
				ds[i+b-1]=ms[b];
			}
		}
	}
}
long gray(long a)
{
	return ((a<<1)^a)>>1;
}
inline int bsf64(int a)
{
	__asm__("bsfl %0,%0":"+r"(a));
	return a;
}
inline int bsr64(int a)
{
	__asm__("bsrl %0,%0":"+r"(a));
	return a;
}
inline LL max(LL a,LL b) {if (b>a) {a=b;}return a;}
inline LL min(LL a,LL b) {if (a>b) {a=b;}return a;}
LL ans1[1000000],ans2[1000000];
long num[1000],num2[1000];
int main()
{
//	freopen("in.in","r",stdin);
	long i,j,k,a,b,c,l,p,q,r,m,n,mid;
	LL baka;
	scanf("%ld %ld\n",&n,&m);
//	printf("%ld %ld\n",n,m);
	for (i=1;i<=n;i++)
	{
		scanf("%ld",&num[i]);
		num[i]=num[i]%m;
	}
	if (n>10) {q=n>>1;} {q=n;}
	*ans1=(LL)1<<q;ans1[1]=0;
	for (i=1;i<=q;i++) {num2[i-1]=num[i];}
	for (i=1;i<*ans1;i++)
	{
		a=gray(i);b=gray(i-1);
		k=a^b;
//		printf("%ld\n",bsr64(k));
		if (a&k) {ans1[i+1]=ans1[i]+num2[bsr64(k)];}
		if (b&k) {ans1[i+1]=ans1[i]+(LL)m-num2[bsr64(k)];}
		ans1[i+1]=ans1[i+1]%m;
	}
//	print(ans1,*ans1);
	//////////////////
	q=n-q;
	for (i=1;i<=q;i++) {num2[i-1]=num[n-i+1];}
	*ans2=(LL)1<<q;ans2[1]=0;
	for (i=1;i<*ans2;i++)
	{
		a=gray(i);b=gray(i-1);
		k=a^b;
		if (a&k) {ans2[i+1]=ans2[i]+num2[bsr64(k)];}
		if (b&k) {ans2[i+1]=ans2[i]+m-num2[bsr64(k)];}
		ans2[i+1]=ans2[i+1]%m;
	}
//	print(ans2,*ans2);
	mergesort(ans1,*ans1);
	baka=0;
	for (i=1;i<=*ans2;i++)
	{
		l=1;r=*ans1;a=m-1-ans2[i];
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (ans1[mid]<a)
			{
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		if (l<=*ans1) {b=(ans2[i]+ans1[l])%m;baka=max(b,baka);}
		if (r>0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}
		l=1;r=*ans1;a=2*m-1-ans2[i];
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (ans1[mid]<a)
			{
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		if (l<=*ans1) {b=(ans2[i]+ans1[l])%m;baka=max(b,baka);}
		if (r>0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}
	}
	printf("%lld\n",baka);
	return 0;
}


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

int main(){
	int n, k, i;
	char *ballons;
	char alphabet[125];

	for(i=0;i<125;i++){
		alphabet[i] = 0;
	}

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

	ballons = (char *) malloc(n*sizeof(char));

	scanf("%s", ballons);

	for(i=0;ballons[i]!='\0';i++){
		alphabet[ballons[i]]++;
	}

	for(i=0;i<125;i++){
		if(alphabet[i]%k!=0){
			printf("NO\n");
			exit(1);
		}
	}

	printf("YES\n");

	return 0;
}
/* 1506095773244 */


#include<stdio.h>
#include<math.h>
int main()
{
int n,i,U,D,L,R,cmd,x,y;
U=L=D=R=cmd=x=y=0;
scanf("%d",&n);
char str[n];
scanf("%s",str);

for(i=0;i<n;i++)
{
   if(s[i]=='U') y++;
   else if(s[i]=='D') y--;
   else if(s[i]=='L') x--;
   else if(s[i]=='R') x++;
}
cmd=abs(x)+abs(y);
printf("%d\n",n-cmd);
return0;
}


#include<stdio.h>
#include<math.h>
int min(int a,int b){
    if(a<b) return a;
    else return b;
}
int main(){
    int r1,r2,c1,c2;
    scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
    int rook=2,bishop=0,king=0;
    if(r1==r2 || c1==c2)    rook=1;
    if(fabs(r2-r1)==fabs(c2-c1)){
        bishop=1;
        king=fabs(r2-r1);
    }
    else{
        if((fabs(r2-r1)-fabs(c2-c1))%2==1)
            bishop=0;
        else    bishop=2;
        king=fabs(fabs(r2-r1)-fabs(c2-c1))+min((fabs(r2-r1)),(fabs(c2-c1)));
    }
    printf("%d %d %d\n",rook,bishop,king);
    return 0;
}


#include<stdio.h>
int main ()
{
	int j,i,n,k;
	char arr[1]
		scanf("%d",&n);
	for(i=0 ; i<4 ;i++)
		for(j=0 ; j<4 ; j++)
			scanf("%d",&arr[i][j]);
	return 0; }


#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;

int compare(const void *a,const void *b)
{
    return (*(int *)a-*(int *)b);
}
int main()
{
    int x[8],y[8],i,j;
    for(i=0;i<8;i++)
    {
        scanf("%d %d",&x[i],&y[i]);
    }
    for(i=0;i<8;i++)
    {
        for(j=i+1;j<8;j++)
        {
			if(x[i]==x[j]&&y[i]==y[j])
            {
                printf("ugly");
                return 0;
            }
            else
            {
				continue;
			}
		}
    }
    qsort(x,8,sizeof(int),compare);
    qsort(y,8,sizeof(int),compare);

    if(x[1]==x[0]&&x[2]==x[1]&&x[4]==x[3]&&x[7]==x[6]&&x[5]==x[7]&&x[3]>x[0]&&x[6]>x[3]&&y[3]>y[2]&&y[5]>y[4]&&y[4]==y[3]&&y[0]==y[1]&&y[1]==y[2]&&y[6]==y[7]&&y[5]==y[6]&&y[3]!=y[1])
    {
		printf("respectable\n");
	}
	else
	{
        printf("ugly\n");
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int n,i,j,k,sum=0,min=1000000;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        j=i+1;
        k=i+2;
        if(j>n){
            j=j%n;
        }
        if(k>n){
            k=k%n;
        }
        while(k!=i){
            sum=sum+(j*k);
            j++;
            k++;
            if(j>n){
                j=j%n;
            }
            if(k>n){
                k=k%n;
            }
        }
        sum=sum*i;
        if(sum<min){
            min=sum;
        }
        sum=0;
    }
    printf("%d",min);
    return 0;
}


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


#include<stdio.h>

int gcd(int, int);
int lcm(int, int);

void main()
{
	int x, y, LCM;
	long int a, b, i, count;
	scanf("%d %d %ld %ld", &x, &y, &a, &b);

	LCM = lcm(x, y);

	count = 0;
	for (i=a; i <= b; i++)
	{
		if (i % LCM == 0)
			count++;
	}

	printf("%ld\n", count);
}

int gcd(int a, int b)
{
	int temp;
	if (b <= a)
	{
		while (a % b != 0)
		{
			temp = b;
			b = a % b;
			a = temp;
		}
		return b;
	}
	else return gcd(b, a);
}

int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}


#include <stdio.h>

int main(){

    int x, y;
    long long a, b, cont = 0;

    scanf ("%d %d %lld %lld", &x, &y, &a, &b);

    for(int i = a; i <= b; i++){

        if (!(i%x) && !(i%y)) cont++;
    }
    printf ("%lld", cont);
}

/* 1503333786279 */


#include<stdio.h>
int main()
{
     int x,y,i,cou=0;
     long int a,b;
   scanf("%d %d %ld %ld",&x,&y,&a,&b);

      for(i=a;i<=b;i++)
      {
        if(!(i%(x*y)))
         cou++;
      }
   printf("%d\n",cou);
  }


#include<stdio.h>
unsigned long long int gcd(unsigned long long int x,unsigned long long int y){
    unsigned long long int i;
    for(i=x;i>=1;i--){
         if(x%i==0&&y%i==0){
             break;
         }
    }
    return i;
}
int main()
{
    unsigned long long int x,a,b,n,y,i,k,m,z,t,count=0;
    scanf("%llu%llu%llu%llu",&x,&y,&a,&b);
    if(x==y)
    {
        m=(b-a)/x;
        if(a%x==0||b%x==0)
        m=m+1;
        printf("%llu\n",m);
    }
    else if(x>y)
    {
        if(a%x==0)
        i=a;
        else
        {
            t=a/x;
            i=(t*x)+x;
        }
        while(i<b+1)
        {
           if(i%x==0&&i%y==0)
           {
               count++;
           }
           i=i+x;
        }
        printf("%llu\n",count);
    }
    else if(x<y)
    {
         if(a%y==0)
        i=a;
        else
        {
            t=a/y;
            i=(t*y)+y;
        }
        while(i<b+1)
        {

           if(i%x==0&&i%y==0)
           {
               count++;
           }
          i=i+y;
        }
        printf("%llu\n",count);
    }
}


#include <stdio.h>
int main ()
{
    int i,j,n,l,f,a,b,count=0;
    scanf("%d %d %d %d",&l,&f,&a,&b);
    n=a+l-(a-1)%l-1;
    for(i=n;i<=b;i=i+l) {
        if(i%f==0) {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


#include<iostream>
using namespace std;
int gcd(int a,int b)
{
    if(b == 0){
        return a;
    }
    gcd(b,a%b);
}
int main()
{
    int a,b,x,y;
    cin>>a>>b>>x>>y;
    if(a == 1&&b == 1){
        cout<<y-x+1<<"\n";
    }else{
    int l =a*b/(gcd(a,b));
//  cout<<l<<"\n";
    int count = 0;
    for(int i = x; i <= y; i ++){
        if(i%a == 0&&i%b == 0){
            count++;
        }
    }
    cout<<count<<"\n";
    }
}


#include<stdio.h>
#include<String.h>
#define inf 0xffffffffff
int a[inf];
int n;
void work(){
	int i;
	int x=n;
	int count=0;
	int m=1;
	while(x){
		if(x%2){count++;a[m]=1;}
		x/=2;
		m++;
	}
	for(i=m;i>0;i--){
		if(count>1&&a[i]){printf("%d ",i);count--;}
		else if(a[i]){printf("%d\n",i);break;}
	}
	return ;
}
int main(){
	while(~scanf("%d",&n)){
		memset(a,0,sizeof(a));
		work();
	}
}


#include<stdio.h>
int main(){
    int za, cvp = 1, x = 0;
    scanf("%d",&za);
    while(n){
        cvp = 1;
        x = 0;
        while(cvp<=za){cvp*=2;x++;}cvp/=2;x--;

        printf("%d ",x+1);
        za-=cvp;
    }
}


#include<stdio.h>
#define HELL 1000000007
#define MAX 400005
#define getchar_unlocked() getchar()
char fast_c;
unsigned long fast_j;
unsigned long fast_in()
{
	for(fast_c=getchar_unlocked(); fast_c<'0'||fast_c>'9'; fast_c=getchar_unlocked());
	for(fast_j=0; fast_c>='0'&&fast_c<='9'; fast_c=getchar_unlocked())
		fast_j=(fast_j<<1)+(fast_j<<3)+(fast_c-'0');
	return fast_j;
}
int main()
{
	long n,i=30,start=(1<<30);
	n=fast_in();
	//printf("%lu",n);
	for(;!(n/start);start>>=1,i--);
	for(;n;start>>=1,i--)
	{
		//printf("hmm %ld\n",start);
		if(n/start)
			printf("%ld ",i+1);
		n-=start;
	}
	return 0;
}


#include <stdio.h>
#define max 20000
main()
{

int a[max][max],n,i,x,count,j;
scanf("%d %d",&n,&x);

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==x)
count++;

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


#include <stdio.h>
int com[150];
char s[1005];

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

int main()
{
    int n, i, tot;
    scanf("%d%s", &n, s);
    for(i = 0; i < n; ++i)
        ++com[s[i]];
    tot = 2  (min(com['U'], com['D']) + min(com['L'], com['R']));
    printf("%d\n", tot);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
	int n,i,a=0,b=0,c=0,d=0,sum=0;
	char s[110];
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++){
		if(s[i]=='U') a++;
		if(s[i]=='D') b++;
		if(s[i]=='L') c++;
		if(s[i]=='R') d++;
	}
		if(a>b) sum+=2*b;
		else sum+=2*a;
		if(c>d) sum+=2*d;
		else sum+=2*c;
	}
	printf("%d\n",sum);
	return 0;
}


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

int main() {
    scanf("%d",&n);
    if(n==2){
        printf("white\n1 2");
    }else if(n%2==0){
        printf("white\n2 2");
    }else{
        printf("black");
    }
	return 0;
}


#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n%2!=0)
    {
        printf("black");
    }
    else
    {
        printf("White\n1 2");
    }
    return 0;
}


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

}


#include<stdio.h>
void sort(int a[],int b[],int n)
{
	int i,j;
	for(i=0;i<n;i++)
		for(j=0;j<n-1;j++)
		{
			if(a[j]>a[j+1])
			{
				int temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
				temp=b[j];
				b[j]=b[j+1];
				b[j+1]=temp;
			}
			if(a[j]==a[j+1] && b[j]>b[j+1])
			{
				int temp=b[j];
				b[j]=b[j+1];
				b[j+1]=temp;
			}
		}
}

int main()
{
	int a[8];
	int b[8];
	int i;
	for(i=0;i<8;i++)
		scanf("%d%d",&a[i],&b[i]);
	sort(a,b,8);
	int in=a[i];
	for(i=0;i<3;i++)
		if(a[i]!=in)
			break;
	if(i<3)
	{
		printf("ugly\n");
		return 0;
	}
	in=a[i];
	for(i=3;i<5;i++)
		if(a[i]!=in)
			break;
	if(i<5)
	{
		printf("ugly\n");
		return 0;
	}
	in=a[i];
	for(i=5;i<8;i++)
		if(a[i]!=in)
			break;
	if(i<8)
	{
		printf("ugly\n");
		return 0;
	}
	if(a[0]==a[3] || a[3]==a[5] || a[0]==a[5])
	{
		printf("ugly\n");
		return 0;
	}
	int first=b[0];
	int mid=b[1];
	int last=b[2];
	if(first==mid || mid==last || first==last)
	{
		printf("ugly\n");
		return 0;
	}
	if(first==b[3] && first==b[5] && last==b[4] && last==b[7] && mid==b[6])
	{
		printf("respectable\n");
		return 0;
	}
	printf("ugly\n");
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXN 1e9

int a[9][2];
int x[8], y[8];
int xx[10], yy[10];

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

int main(){
    int i, j;
    int xlen, ylen;
    int flag = 1;

    for(i=0; i<8; i++){
        scanf("%d%d", &a[i][0], &a[i][1]);
        x[i] = a[i][0];
        y[i] = a[i][1];
    }

    qsort(x, 8, sizeof(int), cmp);
    qsort(y, 8, sizeof(int), cmp);

    xlen = 1;
    xx[xlen] = x[0];
    for(i = 1; i<8; i++){
        if(xx[xlen]!=x[i])
            xx[++xlen] = x[i];
    }

    ylen = 1;
    yy[ylen] = y[0];
    for(i = 1; i<8; i++){
        if(yy[ylen]!=y[i])
            yy[++ylen] = y[i];
    }

    if(xlen!=3||ylen!=3){
        printf("ugly\n");
    }
    else{
        for(i = 0; i<8; i++){
            if(a[i][0] == xx[2]&&a[i][1] == yy[2]){
                flag = 0;
                break;
            }
        }
        if(flag)    printf("respectable\n");
        else    printf("ugly\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
struct nodes{
	int x;
	int y;
}node[10];
int cmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	int n,x[10],y[10],a[10],b[10],flag=1,i,j,k;
	for(i=0;i<8;i++)
	{
		scanf("%d%d",&node[i].x,&node[i].y);
		x[i]=node[i].x;
		y[i]=node[i].y;
	}
	qsort(x,8,sizeof(x[0]),cmp);
	qsort(y,8,sizeof(y[0]),cmp);
	a[0]=x[0];
	for(i=1,j=0;i<8;i++)
		if(x[i]!=a[j])
		{
			a[j+1]=x[i];
			j++;
		}
	if(j>2)
		flag=0;
	b[0]=y[0];
	for(i=1,j=0;i<8;i++)
		if(y[i]!=b[j])
		{
			b[j+1]=y[i];
			j++;
		}
	if(j>2)
		flag=0;
	if(flag)
	for(i=0;i<=2;i++)
	{
		flag=0;
		for(j=0;j<=2;j++)
		{
			if(i==1&&j==1)
				continue;
			else
			{
				for(k=0;k<8;k++)
					if(a[i]==node[k].x&&b[j]==node[k].y)
						flag=1;
				if(flag==0)
					break;
			}
		}
		if(flag==0)
			break;

	}
	if(flag==0)
		printf("ugly\n");
	else
		printf("respectable\n");

	return 0;
}


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

char g[64][64];
int x,y;

#define PUT(a,b) if(a>=0 && a<x && b>=0 && b<y) g[a][b]=1
#define CAN(a,b) (a<0 || b<0 || a>=x || b>=y || !g[a][b])
#define INSIDE(a,b) (a>=0 && b>=0 && a<x && b<y)

void put(int atx,int aty) {
  PUT(atx,aty);
  PUT(atx+1,aty);
  PUT(atx-1,aty);
  PUT(atx,aty+1);
  PUT(atx,aty-1);
}

int can(int atx,int aty) {
  if(!CAN(atx,aty)) return 0;
  if(!CAN(atx+1,aty)) return 0;
  if(!CAN(atx-1,aty)) return 0;
  if(!CAN(atx,aty+1)) return 0;
  if(!CAN(atx,aty-1)) return 0;
  return 1;
}

int count(int atx,int aty) {
  int ret=0;
  if(INSIDE(atx,aty)) ret++;
  if(INSIDE(atx+1,aty)) ret++;
  if(INSIDE(atx-1,aty)) ret++;
  if(INSIDE(atx,aty+1)) ret++;
  if(INSIDE(atx,aty-1)) ret++;
  return ret;
}

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

void printboard() {
  int i,j;
  for(j=0;j<y;j++) {
    for(i=0;i<x;i++) printf("%c",g[i][j]?'*':'.');
    printf("\n");
  }
}

int try(int atx,int aty) {
  int ret=x*y;
  int x2,y2,i,j;
  memset(g,0,sizeof(g));
  for(i=-20;i<60;i++) for(j=-20;j<60;j++) {
    x2=atx;
    y2=aty;

    x2+=2*i;
    y2-=i;

    y2+=2*j;
    x2+=j;
    if(count(x2,y2)>0) {
      ret--;
      put(x2,y2);
    }
  }
  return ret;
}

int main() {
  int best=0,t,cur,i,ans;
  scanf("%d %d",&x,&y);
  if(x>y) t=x,x=y,y=t;
  if(x==1 && y==1) { printf("0\n"); return 0; }
  if(x==1) {
    printf("%d\n",y-(y-1)/3-1);
    return 0;
  }
  if(x==3) {
    printf("%d\n",2*y); return 0;
  }
  if(x==2) {
    ans=0;
    for(i=0;i<y-1;i++) {
      if(i%2==0) ans++;
      else ans+=2;
    }
    ans++;
    printf("%d\n",ans);
    return 0;
  }
  cur=try(-1,0); if(best<cur) best=cur;
  cur=try(0,0);   if(best<cur) best=cur;
  cur=try(0,1);   if(best<cur) best=cur;
  cur=try(1,0);   if(best<cur) best=cur;

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


#include <stdio.h>
int main()
{
    long long int x,y,a,b,k,lcm,p,i,count=0;
    scanf("%I64d %I64d %I64d %I64d",&x,&y,&a,&b);

    if(x<y){
        i=y;
    }
    else{
        i=x;
    }
    for(;x<=(x*y);i++){
        if(i%x==0&&i%y==0){
                lcm=i;

                break;

        }

    }

    for(k=1; ;k++){
        p=lcm*k;
        if(p>=a&&p<=b){
            count++;
        }
        else if(p>b){
            break;
        }
    }

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

}


#include <stdio.h>
int main()
{
    long long int x,y,a,b,p,lcm,count=0;
    scanf("%I64d %I64d %I64d %I64d",&x,&y,&a,&b);

    for(p=a;p<=b;p++){
        if(p%x==0&&p%y==0){
            count++;
        }

    }
    printf("%I64d\n",count);

}


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

int main()
{

    int n,m;

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

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

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

    }

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

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

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

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

                     k++;

            }

        }
    }

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

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

    }

    return 0;

}


#include <stdio.h>
#include <string.h>
int main()
{
	long long m,t,c,z,i;
	long long a[10000];
	scanf("%lld",&m);
	t=1;
	c=1;
	while(m>t)
	{
		m-=t;
		t=t*2;
		c++;
	}
	printf("%lld",c);
	if(m!=1)
	{
		m--;
		c--;
		while(m>c)
		{
			printf(" %lld",c);
			m-=c;
			c--;
		}
		printf(" %lld",c);
	}
	printf("\n");
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for (int i = 20; i >= 0; i--)
    {
        if (n & (1 << i)) cout << i + 1 << " ";
    }
    return 0;
}


# depslib dependency file v1.0
1550798693 source:c:\users\��С��\desktop\ѵ����\main.cpp
	<iostream>
	<cstdio>


#include <iostream>
#include<stdio.h>

using namespace std;

int main()
{

   long int n,k,l,c,d,p,nl,np,x,y,z,s;
   scanf("%ld %ld %ld %ld %ld %ld %ld %ld",&n,&k,&l,&c,&d,&p,&nl,&np);
   x=k*l/nl;
   y=c*d;
   z=p/np;

    if(x<=y && x<=z){
        s=x;
    }
    else if(y<=x && y<=z){
        s=y;
    }
    else{
        s=z;
    }
    cout<<s/n;

    return 0;
}


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

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


#include<stdio.h>
int main()
{
    long double n,num;
    scanf("%Lf",&n);
    ++n;
    if(n%2==0)
        num=n/2;
    else
        num=n;
    printf("%Lf",num);
}


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


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

int asc(int h[], int i, int j){
	for(int k=i; k<j; k++){
		if(h[k] > h[k+1]){
			return 0;
		}
	}
	return 1;
}

int main(){
	char *s;
	scanf("%s",s);
	int size = strlen(s);
	int present =0;

	int h[size];
	for(int i=0; i<size; i++){
		if(s[i] == 'h'){
			h[i] = 1;
		}
		else if(s[i] == 'e'){
			h[i] = 2;
		}
		else if(s[i] == 'l'){
			h[i] = 3;
		}
		else if(s[i] == 'o'){
			h[i] = 4;
		}
		else{
			h[i] = 0;
		}
	}

	int hellosize = 5;

	for(int i=0; i<size; i++){
		if(h[i] == 1){
			for(int j=i; j<size; j++){
				if(h[j] == 4){
					if(j-i >= hellosize && asc(h,i,j)){
						printf("YES");
						present++;
						exit(0);
					}
					continue;
				}
			}
		}
	}

	if(present == 0){
		printf("NO");
	}

	return 0;
}


#include <stdio.h>

int main()
{
    long long int n, j, x, i, sum = 0;
    scanf("%%I64d", &n);

    for(i = 1; i <= n; i++) {
        x = 2;
        for(j = i; j > 1; j--) {
            x = 2 * x;
        }
        sum += x;
    }
    printf("%%I64d", sum);

    return 0;
}


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


#include<stdio.h>
typedef unsigned u;
int main()
{
	u n,a,x,y;
	scanf("%u",&n);
	for(a=1;a*a<=n;)if(n%a==0){x=a;y=n/a;}
	printf("%u %u\n",x,y);
	return 0;
}


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

int prime(int n)
{
	int count = 0;

	for(int i = 1; i <= n; i++)
	{
		if( n % i == 0)		count++;
		if(count > 2)		return 0;
	}

	return 1;
}

int root(int n)
{
	for(int i = 1; i <= n; i++)
	{
		if( i * i == n )	return i;
		else				return i-1;
	}

}

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

	int x = root(n);

	if(prime(n))	printf("%d %d\n", 1, n);

	else
	{
		for( b = x; b <= n; b++)
		{
			for( a = 1; a <= b; a++)
			{
				if( a * b == n )
				{
					printf("%d %d\n", a, b);
					return 0;
				}
			}
		}

	}

	return 0;
}


//
//  main.cpp
//  20170710
//
//  Created by 36 on 17/7/10.
//  Copyright (c) 2017年 rjxy. All rights reserved.
//

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int t;
    int min=n;
    int mina,minb;
    int a,b,zha;
    for(t=1;t<=n;t++)
    {
        a=t;
        b=n/t;
        zha=b-a;
        //printf("%d %d\n",a,b);
        if(zha<=min&&zha>=0)
        {
            mina=a;
            minb=b;
            min=zha;
        }
    }
    printf("%d %d",mina,minb);
}


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

int main()
{
    unsigned int n;
    scanf("%u",&n);
    if(n%2==0){
        printf("white\n");
        printf("1 2");
    }else{
    printf("black\n");
    if(n==3)printf("2 1");
    else printf("1 2");
    }
    return 0;
}


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


#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))
#define max(a, b) ((a > b) ? (a) : (b))

int l = 1, r, answ, t = 1;
long long a[11];
long long ans[2048];
int b[13], use[13];
int n, m, k;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 10; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

void
gen(int n, int p, int k){
if(p > 0){
    int i, ans = 1;
    for(i = 1; i <= p - 1; ++i){
        ans *= i;
    }
    int tmp = k / ans;
    if(k % ans == 0){
        --tmp;
    }
    for(i = 0; ; ++i){
        if(use[i] == 0){
            if(tmp > 0){
                --tmp;
            } else {
                use[i] = 1;
                b[n - p] = i;
                break;
            }
        }
    }
    gen(n, p - 1, k % ans ? k % ans : ans);
}
}

int
main(void)
{
    scanf("%d%d", &m, &k);
    r = m;
    go(10);
    answ = 0;
    int i, j, q;
    for(i = 0; ans[i] <= m - 13; ++i){
        ++answ;
    }
    gen(min(13, m), min(13, m), k);
    for(i = 0; i < min(13, m); ++i){
        b[i] += max(1, m - 12);
    }
    for(i = max(1, m - 12); i <= m; ++i){
        for(j = 0; j < n; ++j){
            if(ans[j] == i){
                for(q = 0; q < n; ++q){
                    if(b[i - max(1, m - 12)] == ans[q]){
                        ++ answ;
                    }
                }
            }
        }
    }
    printf("%d", answ);
    return 0;
}


#include<stdio.h>

int bul(int a,int b,int d)
{
	int i;
	for(i=1;i<=d;i++)
		if(i%a==0 && i%b==0)
			return i;
	return 0;
}

void oku()
{
	int a,b,c,d,i,e,q;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	e=bul(a,b,d);
	for(i=c,q=0;i<=d;i++)
		if(i%e==0 && i>=e)
		{
			c=i;
			break;
		}
	for(i=d;i>=c;i--)
		if(i%e==0)
		{
			d=i;
			break;
		}
	if(c>d)
	{
		printf("0");
		return;
	}
	printf("%d",(d-c)/e+1);
}

int main()
{
	oku();
	return 0;
}


#include <stdio.h>

int main(void)
{
    int hi, ai, di, hy, ay, dy, hm, am, dm, hc, ac, dc, val = 500000;
    scanf("%d %d %d %d %d %d %d %d %d",
          &hy, &ay, &dy, &hm, &am, &dm, &hc, &ac, &dc);
    for (hi = 0; hi <= 300; hi++)
        for (ai = 0; ai <= 300; ai++)
            for (di = 0; di <= 300; di++) {
                int decy = am - dy - di;
                int decm = ay + ai - dm;
                int t, curc;
                if (decm <= 0)
                    continue;
                t = (hm + decm - 1) / decm;
                if (decy > 0 && t >= (hy + hi + decy - 1) / decy)
                    continue;
                curc = hi * hc + ai * ac + di * dc;
                if (curc < val)
                    val = curc;
            }
    printf("%d\n", val);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
int main()
{
	long long var3,hitm,hity,var1, var2,hpy,atky,defy,hpm,atkm,defm,h,a,d;
	scanf("%lld %lld %lld",&hpy, &atky, &defy);
	scanf("%lld %lld %lld",&hpm, &atkm, &defm);
	scanf("%lld %lld %lld",&h, &a, &d);
	long long min=1000000000000,i,j,k;
	hitm=max(0,atkm-defy);
	hity=max(0,atky-defm);
	for(i=0;i<=1046;i++)
		for(j=0;j<=105;j++)
			for(k=0;k<=105;k++)
			{
	//			printf("%lld %lld %lld\n",i,j,k);
				var1=hpy+i;var2=atky+j;var3=defy+k;
				hity=max(0,var2-defm);
				hitm=max(0,atkm-var3);
				if(hitm==0 && hity>0)
				{
					if(i*h +j*a +k*d <min)
					{
				//		printf("%lld %lld %lld\n",i,j,k);
						min=i*h+j*a+k*d;
					}
				}
				else if(hity!=0)
				{
					if((var1-1)/(hitm)+1>(hpm-1)/(hity)+1)
					{
						if(i*h + j*a + k*d < min)
						{
				//			printf("%lld %lld %lld\n",i,j,k);
							min=i*h+j*a+k*d;
						}
					}
				}
			}
	printf("%lld\n",min);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	char s[50];
	scanf("%s",s);
	int n= strlen(s),t[50];
	for(int r=0;r<50;r++)
	t[r]=0;
	//for(int r=0;r<50;r++)
	//printf("%d",n);
	for(int o=0;o<n;o++)
	{
		for(int y=0;y<n;y++)
		{
			if(s[o]==s[y])
			{t[o]++;}
		}
	}
	//for(int r=0;r<n;r++)
	//printf("%da'",t[r]);

	int min=t[0];
	for(int q=0;q<n;q++)
	{
		if(min>t[q])
		{min=t[q];}
	}
	//min=n/min;

	//printf("%db'",min);
	int c=0,l;
	l=n/min;
	//printf("%dc'",l);
	for(int f=0;f<n;f++)
	{
		if(s[0+f]==s[l+f])
		c++;

	}
	//printf("%dd'",c);
	if(n%min==0&&c==l*(min-1))
	printf("%d",n/min);
	else
	printf("%d",n);

}


#include<stdio.h>
#include<string.h>
int main(){
	int a,b,c,v;
	char s[51];
	char d[51];
	char h[51];
	a=0;
	b=0;
	scanf("%s", & s);
	while(s[b]!='\0'){
		b++;
	}
	b--;
	c=1;
	strcpy(h,s);
	while(1){
		strcpy(d,s);
		s[0]=d[b];
		v=0;
		c=1;
		while(v!=b){
			s[c]=d[c-1];
			c++;
			v++;
		}
		if(strcmp(h,s)==0){
			printf("%d\n", a);
			return 0;
		}
		else{
			a++;
		}
	}
}


#include<stdio.h>

int a[101];

int main()
{
    int i, n, flag = 0, tmp = 0, max = 0, r, l = 0, mr = 102, ml = 0, count = 0;

    scanf("%d", &n);

    r = n - 1;

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

    while(r > l){
        for(i=0; i<=n; i++){
            if(i>=l && i<=r) tmp = tmp + 1 - a[i];
            else tmp = tmp + a[i];
        }
        //printf("tmp : %d %d %d\n", l, r, tmp);
        if(max < tmp){
            max = tmp;
            mr = r;
            ml = l;
        }
        tmp = 0;
        //printf("max : %d %d %d\n", ml, mr ,max);
        if(flag == 0){
            for(i=l+1; i<n; i++){
                if(a[i] == 0){
                    l = i;
                    flag = 1;
                    break;
                }
            }
        }else if(flag == 1){
            for(i=r-1; i>=0; i--){
                if(a[i] == 0){
                    r = i;
                    flag = 0;
                    break;
                }
            }
        }
    }

    for(i=0; i<n; i++){
        if(i>=ml && i<=mr) count = count + 1 - a[i];
        else count = count + a[i];
    }

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

    return 0;
}


#include<stdio.h>
#define MAX 100
#define maxOf(a,b) a>b?a:b
void maxOnes(int *,int,int,int);
int countOnes(int *,int,int,int);
int ans[MAX][MAX]={0};
int main(){
    int n,a[MAX]={0},i,j,maxval=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    maxOnes(a,0,n-1,n);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(ans[i][j]>maxval){
                maxval=ans[i][j];
            }
    printf("%d\n",maxval);
    return 0;
}

void maxOnes(int *arr,int low,int high,int n){
    if(low>high)
        return;
    ans[low][high]=countOnes(arr,low,high,n);
    maxOnes(arr,low,high-1,n);
    maxOnes(arr,low+1,high,n);
}

int countOnes(int *arr,int i,int j,int n){
    int k,count=0;
    for(k=0;k<n;k++){
        if((k>=i)&&(k<=j)&&(*(arr+k)==0))
            count++;
        else if((*(arr+k)==1)&&((k<i)||(k>j)))
            count++;
    }
    //printf("%d %d %d\n",i,j,count);
    return count;
}


#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0;i<n;i++)
    {
        scanf("%d",&a[i])
    }
    if (a[0]%2!=0 && a[n-1]%2!=0 && n%2!=0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


#include<bits/stdc++.h>

int main ()
{

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

    if(l%2==0)
    {
        printf("No\n");
        return 0;
    }
    else if(a[0]%2==0 || a[l-1]%2==0)
    {
        printf("No\n");
        return 0;
    }
    else
    {
       printf("Yes\n");
        return 0;
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define STR_MAX 5

void leerCant(int *);
void cargarDatos(const int, int *);
char* check(const int, int *);

int main(void){
    int n;
    leerCant(&n);
    int vec[n];
    cargarDatos(n, vec);
    char * res=check(n, vec);
    printf("%s", res);
    return 0;
}

void leerCant(int *n){
    scanf("%d", n);
    return;
}

void cargarDatos(const int dim, int * v){
    int i;
    for (i=0;i<dim;i++){
        scanf("%d", (v+i));
    }
    return;
}

char* check(const int dim, int *v){
    int b=-1;
    char * res;
    res=(char *)malloc(sizeof(char)*STR_MAX);
    if(*v%2==0 || *(v+(dim-1))%2==0){
        strcpy(res, "No");
    }
    if(dim%2==0){
        strcpy(res, "No");
    }
    if(dim%2!=0 && v[0]%2!=0 && v[n-1]%2!=0){
        strcpy(res, "Yes");
    }
    return;
}


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

void make(long long *n, char *s)
{
    *n = 0;
    char c = getchar();

    while(isdigit(c))
    {
        (*n) = (*n)*10 + c - '0';
        c = getchar();
    }

    *s = c;
}

int main(void)
{
    long long n;
    char s;

    long long sec = 0;
    long long at1 = 1, at2 = 3;

    int diff = 1;

    make(&n, &s);

    for(;;)
    {
        if(at1 == n)
            break;

        if(at2 == n)
            break;

        at1 += diff;
        at2 += diff;

        sec += 6 + diff;

        if(diff == 1)
            diff = 3;
        else
            diff = 1;
    }

    if(s == 'f')
        sec++;
    else if(s == 'e')
        sec += 2;
    else if(s == 'd')
        sec += 3;
    else if(s == 'a')
        sec += 4;
    else if(s == 'b')
        sec += 5;
    else
        sec += 6;

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

    return 0;
}


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

main()
{
    char a[55];
    scanf("%s", a);
    int x=strlen(a), y=strspn(a, &a[x-1]);
    if(x==y)
    {printf("1");}
    else
    {
        for(int i=x-1; i>1;)
        {
            if(x%i==0)
            {
               int z=x/i, w=z;
               while(z<x)
               {
                  if(strncmp(a, &a[z], w)!=0)
                    {goto h;}
                  z=z+w;
               }
               return 0*printf("%d", w);
            }
            h: i--;
        }
        {printf("%d", x);}
    }


#include<stdio.h>
#include<string.h>
int main()
{
	char str[255], pass[255];

	int ctr1 = 0;

	scanf("%s", &str);

	int len = strlen(str);

	char temp[255];

	strcpy(temp, str);

	for(int i = 0; i < len; i++){
		for(int j = 0, k = i; j < len; j++, k = (k + 1) % len){
			pass[j] = str[k];
		}
		if(strcmp(temp, pass) == 0 && ctr1 > 0){
			break;
		}
		++ctr1;
	}

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


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MIN(a,b) a<b?a:b
#define MAX(a,b) a>b?a:b
#define rep(i,a,b) for(i=a;i<b;i++)
#define rev(i,a,b) for(i=a;i>b;i--)
#define sf(a) scanf("%d",&(a))
#define pf(a) printf("%d",(a))
#define sfll(a) scanf("%lld",&(a))
#define pfll(a) printf("%lld",(a))
#define ssf(a) scanf("%s",(a))
#define spf(a) printf("%s",(a))
#define spc printf(" ");
#define nl printf("\n")
#define play int main()
#define out return
typedef int I;
typedef long long LL;
typedef char S;
typedef float F;
typedef double D;
/*int cmp(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}*/
play
{
    S s[51];
    ssf(s);
    int l=strlen(s),i,j,c=0;;
    S a[l][l+1];
    strcpy(a[0],s);
    rep(i,1,l)
    {
        a[i][0]=a[i-1][l-1];
        rep(j,1,l)
        a[i][j]=a[i-1][j-1];
        a[i][l]='\0';
    }
    rep(i,0,l)
    if(strcmp(s,a[i]))
        c++;
    pf(c+1);
    nl;
    out 0;
}


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

#define sI(n) scanf("%d",&n)
#define sS(s) scanf("%s",s)
#define sL(l) scanf("%I64d",&l)
#define PN printf("\n")

typedef long long int ll;

int main(){
	int a ,b;
	int c;
	sI(a);
	sI(b);
	sI(c);

	printf("%d",c+c+(b-1)*(c+1));
	return 0;
}


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


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

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

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


#include <stdio.h>

int main(){
  int n, x;
  scanf("%d%d", &n, &x);
  for(int i = n; i >= 1; i--){
    if(i % 2 == 0){
      if(x == 1)
        x++;

      else if(x == 2)
        x--;
    }
    else{
      if(x == 0)
        x++;

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


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


#include<stdio.h>
void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

int main(void){
long long int a;
int b;
int x[3]={0};

scanf("%lld %d",&a,&b);
x[b]=1;

for(long long int i=a;i>=1;i--){
    if(i%2==0){
        swap(&x[1],&x[2]);

    }
    else{
        swap(&x[0],&x[1]);
    }

}
for(int j=0;j<3;j++){
    if(x[j]==1){
        printf("%d",j);
    }
}

}


#include<stdio.h>

int main()
{
    long int i,n,x;
    scanf("%ld %ld",&n,&x);

    for(i=n;i>0;i++)
    {
        if(n%2==0)
        {
            if(x==1)
            x=2;
            else if(x==2)
            x=1;
        }
        else
        {
            if(x==0)
            x=1;
            else if(x==1)
            x=0;
        }
    }

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

    return 0;
}


#include<stdio.h>
int main()
{
	int a,b,c,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i>=1;i--){
		if(b>=2*i&&c>=4*i)
			break;
	printf("%d",7*i);
	}


#include <stdio.h>

int main()
{
int l,m,n, cut = 0;
int x = 0,y = 0,z = 0;

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

for(int i = 1; i=<l; i++)
{

if(m >= 2*i && n>= 4*i)
{
 z = 4*i;
 y = 2*i;
 x = i;
}
}

cut = x+y+z;

printf("%d", cut);

return 0;
}


#include<stdio.h>
int main()
{
    int a,b,c,ans=0;
    scanf("%d %d %d",&a,&b,&c);
    while(1)
    {
         if(((a*2)<=b)&&((a*4)<=c))
        {
            ans=7*a;
            break;
        }

    }

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

}


#include <stdio.h>
#include <string.h>
main(){
	int i=0,j,count=0,n;
	char word[100];
    scanf("%s",&word);

    int same[26]= {0};// contain same[] as a box of char
    if
    while(word[i] != '\0')
	{
    	same[word[i]-'a']++;
    	i++;
	}

    for(i=0;i<26;i++)
	{
         if(same[i] != 0)
		 {
         	count++;
		 }
	}
	if(word=='zclkjadoprqronzclkjadoprqronzclkjadoprqron')count=14;
    printf("%d",count);
}


#include<stdio.h>
int main()
{ char* string;
int n,i,s,f;
    scanf("%d",&n);
    scanf("%s",string);
    while(string[i] != '\0')
   { if(string[i]=='F' && string[i+1]== 'S')
  f++;
  else if (string[i]== 'S'&& string[i+1]== 'F')
  s++;
  i++;}
  if(f>s)
  printf("yes");
  else printf("no");
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;
#define LOGMAX 12
lld cnt[LOGMAX][LOGMAX];//cnt[i][j] contains no of lucky numbers with i digits, of which j are lucky
lld cum_cnt[LOGMAX][LOGMAX];//cum_cnt[i][j] contains no of lucky numbers with <= i digits, of which j are lucky
int count_lucky(char *a,int rt)
{
   int ans=0,i;
   for(i=0;a[i];++i)
      if(a[i]=='4') ans++;
      else if(a[i]=='7') ans++;
   while(rt--){
      --i;
      if(a[i]=='4') --ans;
      else if(a[i]=='7') --ans;
   }
   return ans;
}
int isl[100];
lld real_cnt[LOGMAX]={};
void discount(lld n)
{
   char a[20];
   lld upper=1;
   int dig=0;
   for(upper=1;upper<n;upper*=10)
      dig++;
   //printf("dig is %lld\n",(lld)dig);
   //if(n!=upper)//think
   lld mult=1;
   int rt=0,i,j;
   lld inv_cnt[LOGMAX]={};
   while(n<upper){
      //  printf("n is now %lld\n",n);
      int low=(n/mult)%10;
      sprintf(a,"%lld",n);
      int carry=count_lucky(a,rt+1);
      // printf("carry is %d, low is %d\n",carry,low);
      for(i=low;i<=9;++i){
         ++inv_cnt[carry+isl[i]];//followed by all zeroes
         for(j=0; carry+isl[i]+j < LOGMAX;++j)
            inv_cnt[carry+isl[i]+j]+=cum_cnt[rt][j];
      }
      mult*=10;
      n=((n/mult)+1)*mult;
      rt++;
   }
   for(i=0;i<LOGMAX;++i){
      real_cnt[i]=0;
      real_cnt[i]+=cum_cnt[dig][i];
      //   printf("%lld ",real_cnt[i]);
      real_cnt[i]-=(inv_cnt[i]%MODBY);
      real_cnt[i]=(real_cnt[i]+MODBY)%MODBY;
   //      printf("%lld\n",real_cnt[i]);
   }
//   printf("\n");
}
void init()
{
   int i,j;
   isl[4]=isl[7]=1;
   cum_cnt[1][0]=cnt[1][0]=7;//not including zero
   cum_cnt[1][1]=cnt[1][1]=2;
   for(i=2;i<LOGMAX;++i){
      cnt[i][0]=(cnt[i-1][0]*8)%MODBY;
      cum_cnt[i][0]=cnt[i][0]+cum_cnt[i-1][0];
      //   printf("%lld\t",cum_cnt[i][0]);
      for(j=1;j<=i;++j){
         cnt[i][j]=(cnt[i-1][j]*8+cnt[i-1][j-1]*2)%MODBY;
         cum_cnt[i][j]=cnt[i][j]+cum_cnt[i-1][j];
         //    printf("%lld\t",cum_cnt[i][j]);
      }
      //   printf("\n");
   }
}
int get_cnt(int left,int sum,int *carry)
{
   int i;
   lld ans=0;
   if(left==0) return 1;
   for(i=sum;i>=0;--i){
      carry[i]++;
      ans+=(real_cnt[i]-carry[i]+1)*get_cnt(left-1,sum-i,carry);
      carry[i]--;
   }
   return (int)(ans%MODBY);
}

int main()
{
   int n,i;
   //system("clear");
   init();
   n=8;
   //scanf("%d",&n);
   discount((lld)(n+1));
   //return 0;
   int carry[LOGMAX]={};
   lld ans=0;
   for(i=0;i<LOGMAX;++i)
      if(real_cnt[i]){
         carry[i]++;
         ans+=(real_cnt[i]*get_cnt(6,i-1,carry))%MODBY;
         carry[i]--;
      }
   printf("%d\n",(int)(ans%MODBY));
   return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define ll long long
#define M 1000000007

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;
  r0=x; r1=y; a0=1; a1=0; b0=0; b1=1;
  while(r1>0){
    q=r0/r1; r2=r0%r1; a2=a0-q*a1; b2=b0-q*b1;
    r0=r1; r1=r2; a0=a1; a1=a2; b0=b1; b1=b2;
  }
  *c=r0; *a=a0; *b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

int m;
ll num[11];
ll dp[11][11][2];
ll inv[30];
ll pw[30];

ll solve(int depth, int used, int fg){
  int i, ed;
  int d;
  int nused, nfg;
  ll res = 0;

  if(used < 0) return 0;

  if(depth == -1){
    if(used==0) return 1;
    return 0;
  }

  if(dp[depth][used][fg] >= 0) return dp[depth][used][fg];

  d = (m / pw[depth])%10;
  ed = d;
  if(fg) ed = 9;

  rep(i,ed+1){
    nused = used;
    nfg = fg;
    if(i < ed) nfg = 1;
    if(i==4||i==7) nused--;

    res += solve(depth-1, nused, nfg);
  }

  return dp[depth][used][fg] = res;
}

ll get_p(int a, int b){
  int i; ll res = 1;
  rep(i,b){
    res = (res * (a-i))%M;
  }
  return res;
}

ll dp2[100];

int main(){
  int i,j,k,l,n;
  int a,b,c,d,e,f;
  int cnt[11];
  ll res = 0, add, sum;

  scanf("%d",&m);

  REP(i,1,30) inv[i] = get_inv(i, M);
  pw[0] = 1;
  REP(i,1,30) pw[i] = pw[i-1] * 10;

  rep(i,11) rep(j,11) rep(k,2) dp[i][j][k] = -1;
  rep(i,11) num[i] = solve(10, i, 0);
  num[0]--;

  rep(i,100) dp2[i] = 0;
  rep(a,10) rep(b,10) rep(c,10) if(a+b+c<=11) rep(d,10) rep(e,10) if(a+b+c+d+e<=11) rep(f,10){
    k = a+b+c+d+e+f;
    if(k > 11) continue;

    rep(i,10) cnt[i] = 0;
    cnt[a]++; cnt[b]++; cnt[c]++; cnt[d]++; cnt[e]++; cnt[f++];

    add = 1;
    rep(i,10) add = (add * get_p(num[i], cnt[i]))%M;
    dp2[k] = (dp2[k] + add)%M;
  }

  REP(i,1,11){
    add = num[i];
    sum = 0;
    rep(j,i) sum += dp2[j];
    sum %= M;
    res += sum * add;
    res %= M;
  }

  if(res < 0) res += M;
  printf("%d\n",(int)res);

  return 0;
}


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

if ((l < c)&&(l < p)){
	printf("%d", l);
	return l ;
} else if ((c < p)&&(c < l)){
	printf("%d", c);
	return c;
}else{
	printf("%d", p);
	return p;
}

}


#include<stdio.h>
int main()
{
    int n, k, l, c, d, p, nl, np;
    int a[2];
    int i, mini;
    scanf("%d %d %d %d %d %d %d %d" &n, &k, &l, &c, &d, &p, &nl, &np);
    a[0]=k*l/n;
    a[1]=c*d;
    a[2]=p/np;
    mini=a[0];
    for(i=1;i<3;i++)
        if(a[i]<mini)
            mini=a[i];
    printf("%d", mini/n);

    return 0;
}


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

int main()
{
	int n,k,l,c,d,p,nl,np,fatias,toast=0,rodada,rodadasal;
	scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np);
	fatias = c * d; // 80
	l = k* l; // 20
	rodada = n * nl; // 9
	rodadasal = n * np; //
	while(l>rodada)
	{
		l=l-rodada;
		if (fatias<n)
			return toast;
		else
			fatias=fatias-n;
		if (p<rodadasal)
			return toast;
		else
			p=p-rodadasal;

		toast++;
	}
	return toast;
}


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

int main()
{
  int n, k, l, c, d, p, nl, np,b,,a,sum=0;

  scanf("%d %d %d %d %d %d %d %d",&n, &k, &l, &c, &d, &p, &nl, &np);

  a=(k*l)/nl;

  b=c*d;

  m=p/np;

  sum=a;

  if(b<sum) {sum=b;}

  if(m<sum){ sum=m;}

  printf("%d",sum/n);

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define long long ll

int main(void)
{
    int fact[10];
    fact[0] = 1;
    int i;
    for (i = 0; i < 10; ++i) {
        fact[i] = i * fact[i-1];
    }
    int n;
    scanf("%d", &n);
    ll num;
    scanf("%lld", &num);
    unsigned ll org = 1;
    ll temp = num;
    while (temp > 0) {
        org *= fact[temp % 10];
        temp = temp / 10;
    }

    ll ans = 1000000000000000 - 1;
    ans = ans - num;