//CodeForces Problem Set 980A

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

int main()
{
	int pearls = 0;
	char necklace[101] = {};
	scanf("%s", necklace);
	int i = 0;
	while (necklace[i] != '\0')
	{
		if (necklace[i] == 'o')
		{
			pearls += 1;
		}
		i += 1;
	}
	int link =  strlen(necklace) - pearls;
	if (link % pearls == 0)
	{
		printf("YES");
		return 0;
	}
	printf("NO");
	return 0;
}


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

int main(){
    char str[100] ;
    scanf("%s",str);
    int a = strlen(str) ;
    int q = 0;
    int w = 0 ;
    for(int i=0;i<a;++i){
        if(str[i]=='o'){
            ++q;
         }
         if(str[i]=='-'){
             ++w;
         }
    }
    if(w%q==0){
        printf("YES");
    }
    if(w%q!=0){
        printf("NO");
    }
    return 0 ;
}


#include<stdio.h>
#include<string.h>
int main() {
int pcount = 0, lcount = 0;
char str[100];
scanf("%s",str);
for (int i = 0; i < strlen(str); i++) {
	if(str[i] == 'o')
		pcount++;
	else if(str[i] == '-')
		lcount++;
	else
		printf("NO");
	}
if(lcount % 2 == 0 || lcount == 0)
	printf("YES");
else if(pcount % 2 == 0 && lcount % 2 == 1)
	printf("NO");
else if(pcount % 2 == 1 && lcount % 2 == 0)
	printf("NO");)
	}


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

int A, min = 0, max = 0;

void run(int a)
{
    int i, remain;

    remain = a%7;
    //result = a/7;
    //printf("remain %d\n", remain);
    //printf("result %d\n", result);

    if (remain==0)
    {
        min = 2*(a/7);
        max = min; return;
    }
    if (remain < 2)
    {
        min = 2*(a/7);
        max = min + 1; return;
    }
    if (remain >= 6)
    {
        min = 1 + 2*((a-1)/7);
        max = 2 + 2*((a-1)/7); return;
    }
    if ((remain >= 2) && (remain < 6))
    {
        min = 2*(a/7);
        max = min + 2; return;
    }
//    min = 2*(a/7)+(remain-5);
//    max = 2*((a-2)/7) + 2;
//    return;
}

int main()
{
    scanf("%d", &A);
    run(A);
    printf("%d %d", min, max);
    return 1;
}


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

int compare(const void *p, const void *q)
{
    int x = *(const int *)p;
    int y = *(const int *)q;
    int ret;
    if (x == y)
      ret = 0;
    else
      ret = (x < y) ? 1 : -1;

    return ret;
}
int main ()
{
int loop , inp=0 , max = 0 , maxp = 0 , rep = 0;
scanf("%d",&inp);
int arr [inp];
    for (loop = 0 ; loop < inp ; loop ++)
          {
    		scanf ("%d",&arr[loop]);
    		if (max == arr[loop])
    			{rep ++;continue ;}
    			if (max < arr[loop])
    			{max = arr[loop] ; maxp = loop; rep = 0;}
          }
    if (maxp == 0 && rep == 0)
    	{printf ("0\n"); return 0 ;}
int sort [inp-1];
for (loop = 0 ; loop <= inp-1 ; loop++)
	sort[loop]=arr[loop+1];
qsort (sort,inp-1,sizeof (int),compare);
for (inp=0;arr[0]<=sort[0];)
		{
			sort[0]--;arr[0]++ ; inp++;
			qsort (sort,inp-1,sizeof (int),compare);
		}
printf ("%d\n",inp);
return 0 ;
}


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


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


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <malloc.h>
#include <stdbool.h>
#include <time.h>
#include <ctype.h>
#define maxn 10

typedef long long ll;

int main()
{
    char Str[maxn][maxn];
    int i, j, cnt1, cnt2;

    cnt1 = cnt2 = 0;
    for( i = 0; i < 8; i ++ )
        for( j = 0; j < 8; j ++ )
            scanf( "%c", Str[i][j] );

    for( i = 0; i < 8; i ++ )
        for( j = 0; j < 8; j ++ )
        {
            if( Str[i][j] == 'Q' )
                cnt1 += 9;
            if( Str[i][j] == 'R' )
                cnt1 += 5;
            if( Str[i][j] == 'B' || Str[i][j] == 'K' )
                cnt1 += 3;
            if( Str[i][j] == 'P' )
                cnt1 += 1;

            if( Str[i][j] == 'q' )
                cnt2 += 9;
            if( Str[i][j] == 'r' )
                cnt2 += 5;
            if( Str[i][j] == 'b' || Str[i][j] == 'k' )
                cnt2 += 3;
            if( Str[i][j] == 'p' )
                cnt2 += 1;
        }

        printf( "%s\n", cnt1 == cnt2 ? "Draw" : ( cnt1 < cnt2 ? "White" : " Black" ) );

    return 0;
}


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

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op = 0;
        while (j < n || i < n)
        {
            op += n - i;
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            op += n - j;
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            if (op > 4e8)
                break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


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

bool reversed(char c, char t)
{
    return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');
}

char reverse(char c)
{
    if (c == 'S')
        return 'N';
    if (c == 'W')
        return 'E';
    if (c == 'N')
        return 'S';
    if (c == 'E')
        return 'W';
    return '\0';
}

int main()
{
    int n;
    assert(scanf("%d", &n) == 1);
    n--;
    char* s = malloc(sizeof(char) * (n + 1));
    char* t = malloc(sizeof(char) * (n + 1));
    assert(scanf("%s", s));
    assert(scanf("%s", t));
    if (reversed(s[n - 1], t[n - 1]))
        printf("NO\n");
        else
    {
        int i = 0;
        int j = 0;
        int ilast = 0;
        int op;
        while (j < n || i < n)
        {
            for (; i < n; i++)
            {
                if (j < n && t[j] == s[i])
                    j++;
                else if (j > 0 && reverse(t[j - 1]) == s[i])
                    j--;
            }
            if (j == n && i == n)
            {
                printf("YES\n");
                return 0;
            }
            for (; j < n; j++)
            {
                if (i < n && t[j] == s[i])
                    i++;
                else if (i > 0 && reverse(s[i - 1]) == t[j])
                    i--;
            }
            op += 2 * n;
            //if (op >= 1e8)
            //    break;
            if (ilast == i)
                break;
            ilast = i;
        }
        if (j == n && i == n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


#include<stdio.h>
int b[501];
void merge(int a[], int k,int l);
void merge_sort(int a[], int n);

int main()
{
    int n,m,k,i,s,flag,a[501];
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    merge_sort(a,n);
    s=k;
    i=0;
    flag=0;
    while(s<m&&i<n&&)
    {
              s=s+a[n-1-i]-1;
              i++;
              if(s>=m) {flag=1;break;}
    }
    if(k!=0&&flag) printf("%d\n",i);
    else printf("-1\n");//getch();
    return 0;
}
void merge_sort(int a[], int n)
{
if(n==1||n==0) return;
merge_sort(a, n/2);
merge_sort(a+n/2, n-n/2);
merge(a,n/2, n-n/2);
}

void merge(int a[], int k,int l)
{
 int i,j=k,c=0;
for(i=0;i<k&&j<k+l;)
{
while(a[i]<a[j]&&i<k){ b[c]=a[i]; c++; i++;} if(i==k) break;
while(a[i]>=a[j]&&j<k+l){ b[c]=a[j];c++; j++;} if(j==k+l) break;
}
if(i<k) {for(;i<k;i++){ b[c]=a[i];c++;}}
else if(j<k+l) { for(;j<k+l;j++){ b[c]=a[j];c++;}}

for(i=0;i<k+l;i++)
  a[i]=b[i];
}


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


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

int main()
{
    char dir;
    int corr = 0;
    char input[101];
    char keyboard[3][10]= {
        'q','w','e','r','t','y','u','i','o','p',
        'a','s','d','f','g','h','j','k','l',';',
        'z','x','c','v','b','n','m',',','.','/'
    };
    scanf("%c", &dir);

    if(dir == 'L'){
        corr = -1;
    }else if(dir == 'R'){
        corr = 1;
    }

    scanf("%s", input);

    for(int i=0; i<strlen(input); i++){
        for(int row=0; row<3; row++){
            for(int col=0; row<10; col++){
                if(keyboard[row][col] == input[i]){
                    printf("%c", keyboard[row][col+corr]);
                }
            }
        }
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=1,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    k=d-1;
    while(k--)
    {
         sum*=2
    }
    sum--;
    n=atoi(ch);
    d--;
    m=1;
    while(d--)
    {
         m=m*10;
    }
    //printf("%d\n",m);
    for(i=m;i<=(m*2);i++)
    {
         c=result(i);
         sum+=c;
         if(i>n)
         break;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}


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

int main()
{
    int n,i,x,count=0,flag=0;
    int a[LEN];
    char ch;

    scanf("%d",&n);

    for(i=1;i<=n;i++)
    {
        x=i;
        int numlen=0;
        flag=0;
        while(x!=0)
        {
            numlen++;
            if(x%10==0 || x%10==1)
            {
                flag++;
            }
            x/=10;

        }
        if(flag==numlen)
        {
            count++;
        }
    }
    printf("%d",count);
    return 0;
}


/*
 * File:   Helpfullmaths.c
 * Author: Wissem
 *
 * Created on 19 novembre 2017, 15:41
 */

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

/*
 *
 */
int main() {
    char s[101],aux;
    scanf("%s",&s);
    for (int i=0;s!='\0';i=i+2)
        for (int j=i+2;s!='\0';j=j+2)

        if (s[i]>s[j]){aux=s[i];
                s[i]=s[j];
                s[j]=aux;}

    printf("%s",s);

}


#include<stdio.h>

int calc(long int a,long int b,long int c){
    if(c==0)
     return 1;
     if(c<0)
      return 0;
    return (calc(a,b,c-a)||calc(a,b,c-b));
}
int main(){
    long int a,b,c;
    int res;
    scanf("%ld%ld%ld",&a,&b,&c);
     res=calc(a,b,c);
     if(res==1)
      printf("Yes");
     else
      printf("No");
}


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


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

#define NB_PARAMS 2

int main ()
{
    int params[NB_PARAMS];

    for (size_t i = 0; i < NB_PARAMS; ++i)
    {
        scanf("%d", &(params[i]));
        while(fgetc(stdin) != '\n');
    }

    printf("%d", (int)ceil((double)params[1] / params[0]));

    return 0;
}


#include <iostream>
int segCalc(int number){
	if(number==4){
		return 4;
	}else if (number==1){
		return 2;
	}else if (number==2||number==5||number==3){
		return 5;
	}else if (number==6||number==0){
		return 6;
	}else if (number==7){
		return 3;
	}else if (number==8){
		return 8;
	}else if (number==9){
		return 7;
	}

}
long findSeg(long i){
	long seg;
	int temp;
	if(i/10==0){
		seg= segCalc(i);
		return seg;
	}
	else{
		temp=i%10;
		seg=segCalc(temp);

		return seg+findSeg(i/10);
	}

}
int main() {
	// your code goes here
	long a,b,sum=0,i;

	scanf("%ld %ld",&a,&b);
	for(i=a;i<=b;i++){

	sum+=	findSeg(i);

	}
	printf("%ld",sum);
	return 0;
}


#include<stdio.h>

int n;
int max1;
int max2;
void max(int x[]){
    int max,i,maxi;
    max2=-1;
    max=0;
    for(i=0;i<n;i++){
        if(x[i]>max){
            max=x[i];
            max1=i;
        }
    }
    maxi=max;
    max=0;
    for(i=0;i<n;i++){
        if(x[i]>max&&x[i]<maxi){
            max=x[i];
            max2=i;
        }
    }
    x[max1]-=x[max2];
}
int main()
{
    int i;
    int x[100];
   scanf("%d",&n);
   for(i=0;i<n;i++){
       scanf("%d",&x[i]);
   }
   while(1){
   max(x);
   if(max2==-1){
       printf("%d",x[0]*n);
    return (x[0]*n);
   }
   }

}


#include <stdio.h>
int main()
{
    int m,n;
    while(scanf("%d %d",&m,&n)) {
        printf("%d\n", (m*n) / 2);
    }
    return 0;
}


// Cola

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

#define ll long long

int count[20000];

void deal(int n, int a, int b, int c)
{
    int i, j;
    ll ans = 0;
    memset(count, 0, sizeof(count));
    for (i = 0; i <= b; i++)
    {
        for (j = 0; j <= c; j++)
        {
            count[i + 2 * j]++;
        }
    }
    for (i = 0; i <= a; i += 2)
    {
        ans += count[n - i / 2];
    }
    printf("%lld\n", ans);
}

int main(int argc, char **argv)
{
    int a, b, c, n;
    while (scanf("%d%d%d%d", &n, &a, &b, &c) == 4)
    {
        deal(n, a, b, c);
    }
    return 0;
}


#include<stdio.h>
int main()

{
    int n,a,b,c,i,count=0,j,k;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(i=c;i>=0;i--)
    {
        if(2*i==n){count++;
        continue;
        }
        for(j=b;j>=0;j--)
        {
            if(2*i+j==n)
            {
                count++;
                continue;
            }
            for(k=0;k<=a;k+=2)
            {
                if(2*i+j+(k/2)==n)count++;
            }
        }

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


#include<stdio.h>
int main()

{
    int n,a,b,c,i,count=0,j,k;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    if(2*c>n)c=n/2;
    if(b>n)b=n;
    if(c/2>n)c=2*n;
    for(i=c;i>=0;i--)
    {
        if(2*i==n){count++;
        continue;
        }
        for(j=b;j>=0;j--)
        {
            if(2*i+j==n)
            {
                count++;
                continue;
            }
            for(k=0;k<=a;k+=2)
            {
                if(2*i+j+(k/2)==n)count++;
            }
        }

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


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


#include <stdio.h>
int main(int argc, char const *argv[]) {
  scanf("%d %d %d\n",&n,&m,&v);
  if (n==1 || m==1 || v==1) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (n==2 && m==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (m==2 && v==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (v==2 && n==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (m==3 && n==3 && v==3) {
    printf("YES\n");
    return 0;
    /* code */
  }
  printf("NO\n" );
  return 0;
}


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

int main()
{
	int i;
	char c;
	char s[200];

	scanf("%s",s);

	i = 1;
	if (strlen(s)<3) { printf("No\n"); return 0; }

	c = 0;

	while (s[i+1])
	{
		if (s[i-1]=='.' || s[i]=='.' || s[i+1]=='.')
		{
			i++;
			continue;
		}
		if (s[i-1]!=s[i] && s[i]!=s[i+1] && s[i-1]!=s[i+1])
		{
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;
}


#include <stdio.h>

int main(int argc, char **argv)
{
	int l,b,i,k;
	scanf("%d""%d""%d",&l,&b,&k);
	for(i=b/2;i=1;i=i-2){
	k=((l*2)+(b-2)*2);
	l=l-2;
	b=b-2;}
	printf("%d",k);
	return 0;
}


#include<stdio.h>
int main(){
int n,k,t,i,x=0 ,j;
scanf("%d%d%d",&n,&k,&t);
if(k==1) printf("1");
else{
for(i=1;i<n+k;i++){
    if(i<=k){
        x++;
    }
    else if(i>k && i<=n) x=k;
    else
        x--;
if(i==t) break;
}
printf("%d",x);
}
return 0;
}


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

   long long int n,k,t,d=0,f=0,i,m=0;
   scanf("%lld %lld %lld",&n,&k,&t);
   if(k>=t){
    printf("%lld",t);
   }
   else if(n<=t&&t<n+k){
        printf("%lld",n+k-t);

   }

   else if(k<=t{

    if(t<=n){
        printf("%lld",k);
    }

   }
   return 0;

}


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

int bsearch(int v, int *a, int h)
{
  int p, l = 0;

  while (l < h) {
    p = (l + h) / 2;

    // printf("%d : %d : %d [%d]\n", l, p, h, a[p]);
    if (a[p] < v)
      l = p + 1;
    else
      h = p;

    // printf("%d %d [%d]\n", l, h, a[p]);
  }

  return l;
}

#define max(a,b) (a>b?a:b)
int main() {
  int n, M;
  int *m_sum;

  // printf("x\n");
  // int x[] = {2,4,4,10};
  // printf("%d\n", bsearch(4,x,3));
  // printf("%d\n", bsearch(2,x,3));
  // printf("%d\n", bsearch(1,x,3));
  // return 0;

  scanf("%d %d", &n, &M);
  m_sum = (int*)malloc(sizeof(int) * n + 1);
  m_sum[0] = 0;
  m_sum++;

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

    t += v;
    int k = 0;
    if (t > M)
      k = bsearch(t - M, m_sum, i) + 1;

    printf("%d ", k);

    for (int j = i; j >= 0; j--)
      m_sum[j] = max(m_sum[j], m_sum[j - 1] + v);
  }
  printf("\n");
}


#include <stdio.h>

int main(){
	int a, b, i, j, end, first, numbers[100], f = 1;
	scanf("%d %d", &a, &b);
	end = b;
	first = a;
	for(i = 0; b > a; i++){
		if (b % 10 == 1){
			b /= 10;
			numbers[i] = b;
		} else{
			if (b % 2 == 0){
				b /= 2;
				numbers[i] = b;
			} else
				f = 0;
		}
	}
	if (b != first)
		f = 0;
	if (f){
		printf("YES\n");
		printf("%d\n", i + 1);
		for(j = i - 1; j >= 0; j--)
			printf("%d ", numbers[j]);
		printf("%d", end);
	} else
		printf("NO");

}


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

int main()
{
    int b1,b2,m1,m2,i;

    scanf("%d %d %d %d",&b1,&b2,&m1,&m2);
    if(m1<=b1&&m2<=b2)
    {
        if(m1==m2&&b2>b1)printf("Second");
        else if(m1==m2&&b1>b2)printf("First");
        else if(m1==m2&&b1==b2)exit(1);
        else if(m1>m2&&b1>=b2)printf("First");
        else if(m1>m2&&b2-m2>=b1-m1)printf("Second");
        else if(m2>m1&&b2>=b1)printf("Second");
        else if(m2>m1&&b1-m1>=b2-m2)printf("First");
        else exit(1);
    }
    else
    {
        if(m1-b1>m2-b2&&m1==m2)printf("Second");
        else if(m1-b1<m2-b2&&m1==m2)printf("First");
        else if(m1-b1>m2-b2)printf("First");
        else if(m1-b1<m2-b2)printf("Second");
        else exit(1);
    }
    return 0;
}


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


#include <stdio.h>

void   caballo (int m[][9], int f, int c)
{
/*8 mov tiene el caballo*/

    /*derecha 1 cuadro*/
  if(c+2<9 && f-1>0)/*9 final del tablero, arriba derecha columna+2*/
  {
    m[f-1][c+2]=1;

  }
    if(c+1<9 && f-2>0)/*9 final del tablero, arriba derecha columna+1*/
  {
    m[f-2][c+1]=1;
  }

  /*abajo derecha*/
    if(c+1<9 && f+2<9)/*9 final del tablero, arriba derecha colu+1*/
  {
    m[f+2][c+1]=1;
  }
    if(c+2<9 && f+1<9)/*9 final del tablero, arriba derecha colu+2*/
  {
    m[f+1][c+2]=1;
  }

  /*izquierda arriba*/
    if(c-1>0 && f-2>0)/* arriba del tablero, arriba izquierda fi-2*/
  {
    m[f-2][c-1]=1;
  }
    if(c-2>0 && f-1>0)/*arriba del tablero, arriba derecha fi-1*/
  {
    m[f-1][c-2]=1;
  }

  /*izquierda abajo*/
    if(c-1>0 && f+2<9)/*9 final del tablero, arriba derecha fi+2*/
  {
    m[f+2][c-1]=1;
  }
    if(c-2>0 && f+1<9)/*9 final del tablero, arriba derecha co+1*/
  {
    m[f+1][c-2]=1;
  }
  /*fin funcion*/

}

void torre (int m[][9], int f,int c)
{
    int aux;

    /*fila torre llenar de 1s*/
    for(aux=1; aux<=8; aux++)
    {
        m[f][aux]=1;
    }

        /*fila torre llenar de 1s*/
    for(aux=1; aux<=8; aux++)
    {
        m[aux][c]=1;
    }

}

void inici (int m[][9])
{
    int i,j;
    /*imprimir matriz*/
    for(i=1; i<9; i++){
        for(j=1; j<9; j++)
            m[i][j]=0;

    }
}

void resultado(int m[][9])
{
    int i,j,con=0;
    /*imprimir matriz*/
    for(i=1; i<9; i++){
        for(j=1; j<9; j++)
            if(m[i][j]==0)
                con++;
    }

    printf("%d",con);
}

main()
{

int ma[9][9]={0};
int i,j,i2;
char c;

/*primera linea entra torre*/
scanf("%c %d",&c,&i);
j=(int)c-'a';
j++; /*se pasa la letra a numero +1*/
i=9-i;/*posicion de fila invertida*/

inici(ma);
ma[i][j]=1;/*primera linea*/

/*se colocan 1s para la posicion del caballo y torre*/
caballo (ma,i,j);
torre (ma,i,j);

/*segunda linea*/
scanf("%1s %d",&c,&i2); /*guarda un solo caracter en la variable*/

j=(int)c-'a';
j++; /*se pasa la letra a numero +1*/
i2=9-i2;/*posicion de fila invertida*/
ma[i2][j]=1;/*primera linea*/

/*se colocan 1s para la posicion del caballo y torre*/
caballo (ma,i2,j);

resultado(ma);

    return 1;
}


#include <stdio.h>

char piece[4];

int rx, ry, kx, ky;

int abs(int a){ return a < 0 ? -a : a; }

int ok(int x, int y){
    int dx = abs(x - kx), dy = abs(y - ky);
    if(abs(dx - dy) == 1 && dx + dy == 3) return 0;
    dx = abs(x - rx), dy = abs(y - ry);
    if(abs(dx - dy) == 1 && dx + dy == 3) return 0;
    return x != rx && y != ry && (x != kx || y != ky);
}

int main(){
    int ans = 0, i, j;
    scanf("%s", piece); rx = piece[0] - 'a', ry = piece[1] - '1';
    scanf("%s", piece); kx = piece[0] - 'a', ky = piece[1] - '1';
    for( i = 0; i < 8; ++i){
        for( j = 0; i < 8; ++j){
            ans += ok(i,j);
        }
    }
    printf("%d\n", ans);
    return 0;
}


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


#include<stdio.h>

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

        m= (2*n*n)+1-(2*n);
        printf("%d\n", m);
    }

    return 0;
}


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

int main() {
	int n, e, o;

	scanf("%d", &n);
	if (n <= 5) {
		printf(n == 3 ? "0\n" : "1\n");
		return 0;
	}
	e = 4, o = 5;
	if (e < n && o < n) {
		int o_ = e + e + 1;
		int e_ = e + o + 1;

		e = e_, o = o_;
		if (e == n || o == n) {
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
	return 0;
}


#include<stdio.h>

#define MOD 998244353
int fact[1000006], wpar[1000006<<1], n, level;

int mul(int a, int b){
  return (a*1ll*b)%MOD;
}

int powmod(int p, int b){
  int t = 1;
  while(p){
    if(p&1)t = mul(t, b);
    b = mul(b, b);
    p>>=1;
  }
  return t;
}

int ncr(int n, int r){
  return mul(mul(fact[n], powmod(fact[r], MOD - 2)), powmod(fact[n - r], MOD - 2));
}

void dfs(int x, int bits){
  if(bits > level) return;
  int l, r;
  l = x<<1;
  r = l|1;
  if(x&1){
    // x is a right child
    wpar[l] = 1;
    wpar[r] = 1^wpar[x]^wpar[l];
  } else {
    // x is a left child
    wpar[r] = 0;
    wpar[l] = 1^wpar[x]^wpar[r];
  }
  dfs(l, bits + 1);
  dfs(r, bits + 1);
}

int getpossib(int lparity){
  int i, rem, choice;
  wpar[2] = lparity;
  wpar[3] = wpar[1]^wpar[2];
  dfs(2, 2);dfs(3, 2);

  rem = n - (1<<level) + 1;
  choice = 0;
  for(i = (1<<(level - 1));i < (1<<level);i++){
    if(i&1){
      if(wpar[i]) return 0;
      rem--;
      choice++;
    } else {
      choice++;
      if(1^wpar[i]) rem--;
      else choice++;
    }
  }

  if(rem < 0 || rem&1 || (rem>>1) > choice) return 0;
  return ncr(choice, rem>>1);
}

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

  fact[0]  = 0;
  for(i = 1;i < 1000006;i++)fact[i] = mul(fact[i - 1], i);

  if(n == 1 || n == 2 || n == 4 || n == 5){printf("1\n");return 0;}
  if(n == 3 || n == 6 || n == 7){printf("0\n");return 0;}

  for(level = 0; (1<<level) - 1 < n;level++);
  level -= 2;
  wpar[1] = n&1;

  int ans;
  ans = (getpossib(0) + getpossib(1))%MOD;

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

  return 0;
}


#include <stdio.h>
int main()
{
    int HH,MM,z,y;
    double  x;
    scanf("%d%d",&HH,&MM)；
        if (HH==12)
            z=0;
        else
            z=HH*30;
        x=z+(double)MM/2;
        y=MM*6;
        printf("%g %d\n",x,y);
    return 0;
}


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

int main()
{
    double ha,ma;
    int h,m;
    char ch;
    while(1)
    {
        scanf("%d%c%d",&h,&ch,&m);
        if(h>=12 )
            h=h-12;
        ha=h*30+m/2.0;
        ma=m*6;
        printf("%lg %lg\n",ha,ma);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int arr[101];
int n,dis;
int min(int x,int y)
{
	return x<y?x:y;
}
int comparator (const void * b, const void * a)
{
  return ( *(int*)b - *(int*)a );
}
int recur(int start,int end)
{
	if(start==end)
	 return 0;
	if(arr[end]-arr[start]<=dis)
	 return 0;
	int q1=recur(start+1,end);
	int q2=recur(start,end-1);
	return 1+min(q1,q2);
}
int main()
{
	scanf("%d %d",&n,&dis);
	//printf("%d\n",dis);
	int i,j,k;
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
	}

	qsort(arr,n,sizeof(int),comparator);

	printf("%d\n",recur(0,n-1));
}


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


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int distance(int a, int b){
    int k= 10*abs(a-b);
    return k;
}
int main(){
    int n, m, k, *p, i, dummy=0, dist=10000;
    scanf("%d%d%d", &n, &m, &k);

    p=int*malloc(n*sizeof(int));
    for(i=0;i<n;i++){
        scanf("%d", &p[i]);
    }
    for(i=0;i<n;i++){
        if(p[i]!=0 && p[i]<=k){
            if(distance(i, m)<dist){
                dist=distance(i, m);
                dummy=i;
            }else continue;
        }else continue;
    }
    printf("%d\n", dist);
    free p;
    return 0;
}


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

int main()
{
	int n,pisition,money,i,j;
	int min=9999,output;

	scanf("%d %d %d",&n,&pisition,&money);

	int num[n];

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

	for(i=0;i<n;i++)
	{
		if(num[i]==0||num[i]>money)
		{
			continue;
		}

		output=(abs)(i+1-pisition)*10;

		if(output<min)
		{
			min=output;
		}
	}

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

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i,j=1,l=1,k,n,m;
	scanf("%d %d %d",&n,&m,&k);
	int a[n];
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	while(1)
	{
		if(m+j<=n)
		if(k>=a[m+j] && a[m+j]!=0)
		{
			printf("%d",j*10);
			break;
		}
		else if(m-l>0)
		if(k>=a[m-l] && a[m-l]!=0)
		{
			printf("%d",l*10);
			break;
		}
		j++;
		l++;
	}
}#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i,j=1,l=1,k,n,m;
	scanf("%d %d %d",&n,&m,&k);
	int a[n];
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	while(1)
	{
		if(m+j<=n)
		if(k>=a[m+j] && a[m+j]!=0)
		{
			printf("%d",j*10);
			break;
		}
		else if(m-l>0)
		if(k>=a[m-l] && a[m-l]!=0)
		{
			printf("%d",l*10);
			break;
		}
		j++;
		l++;
	}
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i,j=1,l=1,k,n,m;
	scanf("%d %d %d",&n,&m,&k);
	int a[n];
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	while(1)
	{
		if(m+j<=n)
		if(a[m+j]!=0 && k>=a[m+j])
		{
			printf("%d",j*10);
			break;
		}
		else if(m-l>0)
		if(a[m-l]!=0 && k>=a[m-l])
		{
			printf("%d",l*10);
			break;
		}
		if(m+j<=n)
		j++;
		if(m-l>0)
		l++;
	}
}


#include <stdio.h>

int main()
{
	int v1=0,v2=0,t=0,d=0;
	scanf("%d %d %d %d",&v1,&v2,&t,&d);
	int totalPathCovered=v2,i;
	int samplesLeft;
	t=t-1;
	for(i=1;i<=t;i++)
	{
		if(((v2+d-v1)/(t-i))<d)
		{
			v2+=d;
			totalPathCovered+=v2;
		}
		else
		{
			v2=(d*(t-i))+v1;
			samplesLeft=t-i;
			totalPathCovered+=v2;
			break;
		}

	}
	totalPathCovered+=((samplesLeft*(v2-d+v1)/2));
	printf("%d\n",totalPathCovered);
	return 0;
}


#include <stdio.h>
int main()
{int a,b,c,d,e,f,i,j,k,sum=0,p,q=0,r,x,y,z;
 scanf("%d %d",&a,&b);
 scanf("%d %d",&c,&d);
 if(d==0)
 {sum=a*c;}
 else if(d!=0)
 {sum=a+b;
  c=c-2;
  p=d;
  x=a;
  for(i=c;i>0;i--)
  {

        while(p>=0)
        {          x=x+p;
                     if((x-b)/i<=d)
        {
                     sum=sum+x;
                     break;
        }
        else
        {            x=x-p;
                     p=p-1;
        }}
        if(p==0)
        {           x=x-q;
                     while(q<=d)
                     { if((x-b)/i>=1)
                        {
                                     sum=sum+x;
                        }
                        else
                        {
                                     x=x-q;
                                     q=q+1;
                        }

                     }
        }
        }

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


#include <stdio.h>

int main(void)
{
    float a, b, n, mod, sum, div, i, j;
    scanf("%f", &n);
    scanf("%f", &a);
    scanf("%f", &b);

    sum = a + b;
    div = sum/n;
    if(div >= a) printf("%d", (int)a);
    else if (div >=b) printf("%d",(int) b);

    else
        {
            while(n >= (i+j))
            {
                i = (int)(a/div);
                j = (int)(b/div);
                div--;
            }
            printf("%d",(int)(div+1));
        }
    }


#include <stdio.h>

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int low=1;
    int high=(a+b+n-1)/n;
    int ans=0;
    while(low<=high)
    {
        int mid=(low+high)/2;
        if(a/mid+b/mid>=n)
        {
            if(a/(mid+1)+b/(mid+1)<n) {ans=mid;break;}
            low=mid;
        }
        else
            high=mid-1;
    }
    printf("%d\n",ans);
    return 0;
}


#include <stdio.h>
int maximum(float num1, float num2);

int main(void)
{
    float a, b, c, d, max;
    scanf("%f\n%f\n%f\n%f", &a, &b, &c, &d);

    if(a<=250 || b >= 3500 || c <= 0 || d>= 180)
    {
        exit(1);
    }

    float misha1, misha2, vasya1, vasya2, result1, result2;

    misha1 = (3 * (a / 10));
    misha2 = (a - ((a / 250) * c));

    result1 = maximum(misha1, misha2);

    vasya1 = (3 * (b / 10));
    vasya2 = (b - ((b / 250) * d));

    result2 = maximum(vasya1, vasya2);

    if (result1 > result2)
    {
        printf("Misha");

    }
    else if (result1 < result2)
    {
        printf("Vasya");
    }
    else
    {
        printf("Tie");

    }
    return 0;
}

int maximum(float num1, float num2)
{
    return (num1 > num2) ? num1 : num2;
}


#include <stdio.h>
long long int i,j,k,m,n,x,y,z,B[1000],a,max=-100;
int main()
{
    scanf("%lld",&a);
    for (i = 1000000; i >=1 ; i--)
    {
        while(n%(i*i)==0)
        {
            n=n/i;

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

return 0;
}


#include<iostream>
using namespace std;
int main()
{
long long n,i;
scanf("%lld",&n);
for( i=1000000;i>1;i--)
while(n%(i*i)==0)
n=n/i;
printf("%d",n);
return 0;
}


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

long long int n, a, i, j, p[1000005], carp = 1;

int main () {
	scanf("%lld",&n);
	a = n;
	while(a != 1){
		for(j = 2 ; j <= n ; j++){
			if(a%j == 0){
				a/=j;
				p[j]++;
				break;
			}
		}
	}
	for(i = 0 ; i < 1000000 ; i++){
		if(p[i])
			carp*=i;
	}
	printf("%lld",carp);
	return 0;
}


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

long long int n, a, i, j, p[100000005], carp = 1;

int main () {
	scanf("%lld",&n);
	a = n;
	while(a != 1){
		for(j = 2 ; j <= n ; j++){
			if(a%j == 0){
				a/=j;
				p[j]++;
				break;
			}
		}
	}
	for(i = 0 ; i < 1000000 ; i++){
		if(p[i])
			carp*=i;
	}
	printf("%lld",carp);
	return 0;
}


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

    return 0;
 }


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


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

main()
{
    long long int i,j,k,a,n,m,sum=0,max;
    scanf("%lld %lld",&a,&n);
    for(i=a;i<a+n;i++)
    {
        max=0;
        for(j=1;j*j<=i;j++)
        {
            if(((i%(j*j))==0)&&j>max)
            {
                max=j;
                m=i/(j*j);
            }
        }
        //printf("%lld\n",max);
        sum+=m;
    }
    printf("%lld\n",sum);
    return 0;

}


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

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

	if (M > N) M = N;

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

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

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

	ans = M + k;

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

	return 0;
}


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

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

    int x1=0;
    if(m==0||m==1)
    {
        printf("1");
        return 0;
    }
    if(n==m)
    {
        printf("0");
        return 0;
    }
    if((n-1)%2==0)
    {
        x1=(n-1)/2;
        if(x1>m)
            x1=m;
        printf("%d",x1);
        return 0;
    }
    else
    {
        x1=(n-1)/2+1;
        if(x1>m)
            x1=m;
        printf("%d",x1);
        return 0;
    }
}


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

int main()
{
    int max,m,n;
    scanf("%d%d",&n,&m);
    if(m>n)
        exit(0);
    if(m==0||m==1)
 {
    printf("1");
    exit(0);
 }
    if(n==m)
        {printf("0");
        exit(0);}
    if(n%2==0)
    {
        max=n/2;
       if(m<max)
        printf("%d",m);
        else if(m>max)
            printf("%d",2*max-m);
        else
        printf("%d",max);
    }
    if(n%2==1)
    {
        max=(n-1)/2;
        if(m<max)
        printf("%d",m);
        else if(m==max||m==max+1)
            printf("%d",max);
        else
        printf("%d",2max-m+1);
    }
    return 0;
}


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

    if(m<(n/2))
    {
        printf("%d",m);
        return;
    }

    int left = n/2 - m;

    printf("%d",m)
}


#include <stdio.h>

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int res = 0;
    if(m == 0){
            res = 1;
    }else {
        if(m <= (n/2)){
            res = m;
        }else{
            res = n - m;
        }
    }
    printf("%d", res);
    return 0;
}
7


#include<stdio.h>
#include<string.h>
long long no=1000000007;
main()
{
    char s[200];
    scanf("%s",s);
    int len =strlen(s);
    if(len==1)
    {
        if(s[0]=='1')
            printf("1");
        else
          printf("0");
        return 0;
    }
    int i;
    long long no1=0,no2=1,no3,power=1,flag=0;
    for(i=len-1;i>=0;i--)
    {
        no1=(no1+power*(s[i]-'0'))%no;
        power=(power*2)%no;
        if(s[i]=='0')
            flag=1;
    }
    for(i=1;i<len;i++)
        no2=no2*2;
        if(flag==0)
        printf("%I64d",(no1*(no1+1)/2)%no);
        else
        printf("%I64d",(no1*no2)%no);
        return 0;
}


#include <stdio.h>

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

	scanf("%lld%lld", &a, &b);
	c = 1;
	while (a > 1 || b > 1) {
		if (a > b)
			a -= b;
		else
			b -= a;
		c += 1;
	}
	printf("%lld\n", c);

	return 0;
}


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

/* A function that prints given number in words */
void convert_to_words(char *num)
{
    int len = strlen(num);  // Get number of digits in given number

    /* Base cases */
    if (len == 0) {
        fprintf(stderr, "empty string\n");
        return;
    }
    if (len > 4) {
        fprintf(stderr, "Length more than 4 is not supported\n");
        return;
    }

    /* The first string is not used, it is to make array indexing simple */
    char *single_digits[] = { "zero","one","two","three","four",
                              "five","six","seven","eight","nine"};

    /* The first string is not used, it is to make array indexing simple */
    char *two_digits[] = {"", "ten", "eleven", "twelve", "thirteen", "fourteen",
                     "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};

    /* The first two string are not used, they are to make array indexing simple*/
    char *tens_multiple[] = {"", "", "twenty", "thirty", "forty", "fifty",
                             "sixty", "seventy", "eighty", "ninety"};

    char *tens_power[] = {"hundred", "thousand"};

    /* Used for debugging purpose only */

    /* For single digit number */
    if (len == 1) {
        printf("%s\n", single_digits[*num - '0']);
        return;
    }

     /* Iterate while num is not '\0' */
     while (*num != '\0') {

        /* Code path for first 2 digits */
        if (len >= 3) {
            if (*num -'0' != 0)
            {
                printf("%s", single_digits[*num - '0']);
                printf("%s", tens_power[len-3]); // here len can be 3 or 4
            }
            --len;
        }

        /* Code path for last 2 digits */
        else {
            /* Need to explicitly handle 10-19. Sum of the two digits is
               used as index of "two_digits" array of strings */
            if (*num == '1') {
                int sum = *num - '0' + *(num + 1)- '0';
                printf("%s\n", two_digits[sum]);
                return;
            }

            /* Need to explicitely handle 20 */
            else if (*num == '2' && *(num + 1) == '0') {
                printf("twenty\n");
                return;
            }

            /* Rest of the two digit numbers i.e., 21 to 99 */
            else {
                int i = *num - '0';
                printf("%s", i? tens_multiple[i]: "");
                ++num;
                if (*num != '0')
                    printf("-%s", single_digits[*num - '0']);
            }
            printf("\n");
        }
        ++num;
    }
}
int main(void)
{   while(1)
    {char a[33];
    scanf("%s",&a);
    convert_to_words(a);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int n;
    char english[100][20]={"","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen"
                            ,"fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
    while(1){
        scanf("%d",&n);
    if(n<20) printf("%s",english[n]);
    if(n==20) printf("twenty");
    if(n==30) printf("thirty");
    if(n==40) printf("forty");
    if(n==50) printf("fifty");
    if(n==60) printf("sixty");
    if(n==70) printf("seventy");
    if(n==80) printf("eighty");
    if(n==90) printf("ninety");
    if(n==0) printf("zero");
    if(n>20&&n<30) printf("twenty-%s\n",english[n%10]);
    if(n>30&&n<40) printf("thirty-%s\n",english[n%10]);
    if(n>40&&n<50) printf("forty-%s\n",english[n%10]);
    if(n>50&&n<60) printf("fifty-%s\n",english[n%10]);
    if(n>60&&n<70) printf("sixty-%s\n",english[n%10]);
    if(n>70&&n<80) printf("seventy-%s\n",english[n%10]);
    if(n>80&&n<90) printf("eighty-%s\n",english[n%10]);
    if(n>90&&n<100) printf("ninety-%s\n",english[n%10]);}
    return 0;
}


#include<stdio.h>
int x[100100];
int main()
{
long long i,j,k,n,max,min;
max=0;
min=-1;
scanf("%I64d",&n);
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
{
    if(i*j>n)
        break;

            else if(i*j==n)
            {

        if(min==-1)
            min=(i+2)*(j+2);
        else if((i+2)*(j+2)<min)
            min=(i+2)*(j+2);
            }

    }
max=3*3*(n+1);

	printf("%I64d %I64d\n",min*2-n,max-n);
	return 0;
}


#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[50];
    scanf("%s",s);
    int n=0;
    int a;
    a=strlen(s);
    for (size_t i = 0; i < 50; i++)
    {
        if (s[i]=='a')
        {
            n++;
        }

    }
    if (n+n-1>a)
    {
       printf("%s",n);
    }
    else
    {
        printf("%s",a);
    }

}


#include<stdio.h>
#include<stdlib.h>
int main(){
    long int a,b,s;
    scanf("%ld%ld%ld",&a,&b,&s);
    long int x=abs(a),y=abs(b);
    if(s>=(x+y) && (s%(x+y))%2==0){
        printf("YES");
    }
    else{
        printf("NO");
        }
}


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

#define N	100000
#define MD	1000000007

int ff[N], gg[N];

int d_, x_, y_;

void gcd_(int a, int b) {
	if (b == 0) {
		d_ = a;
		x_ = 1, y_ = 0;
	} else {
		int tmp;

		gcd_(b, a % b);
		tmp = x_ - a / b * y_, x_ = y_, y_ = tmp;
	}
}

int inv(int a, int b) {
	gcd_(a, b);
	return x_;
}

void init(int n) {
	int i, f;

	for (i = 0, f = 1; i < n; i++) {
		gg[i] = inv(ff[i] = f, MD);
		f = (long long) f * (i + 1) % MD;
	}
}

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

int main() {
	static int aa[N + 2], bb[N + 2], cc[N + 2];
	int f, w, h, n, i, j, p, q, ans;

	scanf("%d%d%d", &f, &w, &h);
	if (f == 0) {
		printf("%d\n", w > h);
		return 0;
	}
	if (w == 0) {
		printf("1\n");
		return 0;
	}
	n = f > w ? f : w;
	init(n);
	for (i = 1; i <= f; i++)
		aa[i] = choose(f - 1, i - 1);
	for (j = 1; j <= w; j++)
		bb[j] = choose(w - 1, j - 1);
	for (j = 1; h * j < w; j++)
		cc[j] = choose(w - h * j - 1, j - 1);
	p = q = 0;
	for (i = 1; i <= n; i++) {
		p = (p + aa[i] * (cc[i] * 2LL + cc[i - 1] + cc[i + 1])) % MD;
		q = (q + aa[i] * (bb[i] * 2LL + bb[i - 1] + bb[i + 1])) % MD;
	}
	ans = (long long) p * inv(q, MD) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


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

#define N	100000
#define MD	1000000007

int ff[N], gg[N];
int d_, x_, y_;

void gcd_(int a, int b) {
	if (b == 0) {
		d_ = a;
		x_ = 1, y_ = 0;
	} else {
		int tmp;

		gcd_(b, a % b);
		tmp = x_ - a / b * y_, x_ = y_, y_ = tmp;
	}
}

int inv(int a, int b) {
	gcd_(a, b);
	return x_;
}

void init(int n) {
	int i, f;

	for (i = 0, f = 1; i < n; i++) {
		gg[i] = inv(ff[i] = f, MD);
		f = (long long) f * (i + 1) % MD;
	}
}

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

int main() {
	static int aa[N + 2], bb[N + 2], cc[N + 2];
	int f, w, h, n, i, j, p, q, ans;

	scanf("%d%d%d", &f, &w, &h);
	if (f == 0) {
		printf("%d\n", w > h);
		return 0;
	}
	if (w == 0) {
		printf("1\n");
		return 0;
	}
	n = f > w ? f : w;
	init(n);
	for (i = 1; i <= f; i++)
		aa[i] = choose(f - 1, i - 1);
	for (j = 1; j <= w; j++)
		bb[j] = choose(w - 1, j - 1);
	for (j = 1; h * j < w; j++)
		cc[j] = choose(w - h * j - 1, j - 1);
	p = q = 0;
	for (i = 1; i <= n; i++) {
		p = (p + aa[i] * (cc[i] * 2LL + cc[i - 1] + cc[i + 1])) % MD;
		q = (q + aa[i] * (bb[i] * 2LL + bb[i - 1] + bb[i + 1])) % MD;
	}
	if (p < 0)
		p += MD;
	if (q < 0)
		q += MD;
	ans = (long long) p * inv(q, MD) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#define MOD 1000000007

long long mpow(long long a, long long p)
{
  a %= MOD;

  long long r = 1;
  while (p) {
    if ((1 & p)) r = (r * a) % MOD;
    a = (a * a) % MOD;
    p >>= 1;
  }
  return r;
}

int inv(long long x)
{ return mpow(x, MOD-2); }

#define MAXF 100005

int factorial[MAXF];

long long possib(long long width, long long boxes, long long minh)
{
  long long separators = width-1;
  long long elements = boxes-width*minh;

  if(elements < 0) return 0;
  else return (factorial[separators+elements]*inv(factorial[separators]*factorial[elements])) % MOD;
}

long long all_possib, nice_possib;
void add_all(long long x)
{
  x %= MOD;
  all_possib += x;
  all_possib %= MOD;
}
void add_nice(long long x)
{
  x %= MOD;
  nice_possib += x;
  nice_possib %= MOD;
}

int main()
{
  long long fac;
  int i;
  int result;

  i = 0;
  for(fac = 1; i<MAXF; fac = fac*i % MOD){
    factorial[i] = fac;
    i++;
  }

  int F, W, H, width;
  scanf("%d %d %d\n", &F, &W, &H);

  if(W == 0 || F == 0){
    if(W == 0 || W > H) printf("1\n");
    else printf("0\n");
    return 0;
  }

  all_possib = 0;
  nice_possib = 0;
  for(width=1; width<=W; width++){
    add_all(possib(width, F, 1)*possib(width, W, 1));
    add_all(possib(width+1, F, 1)*possib(width, W, 1));
    add_all(possib(width, W, 1)*possib(width, F, 1));
    add_all(possib(width+1, W, 1)*possib(width, F, 1));

    add_nice(possib(width, F, 1)*possib(width, W, H+1));
    add_nice(possib(width+1, F, 1)*possib(width, W, H+1));
    add_nice(possib(width, W, H+1)*possib(width, F, 1));
    add_nice(possib(width+1, W, H+1)*possib(width, F, 1));
  }
  result = nice_possib*inv(all_possib) % MOD;

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

  return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    char s[200];
    int k=0,len=0,index=0,i=0,flag=0;
    scanf("%s",s);
    len=strlen(s);
    scanf("%d",&k);
    if((len+k)%2!=0) { index++;}
    while(1)
    {
        int mid=index+ (len+k-index)/2;
        for(i=0;mid+i<len;i++)
        {
            if(s[index+i]!=s[mid+i]) break;
        }
        if(mid+i==len) break;
        index+=2;
    }
    printf("%d",len+k-index);
return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    char s[200];
    int k=0,len=0,index=0,i=0,flag=2,count1;count2;
    scanf("%s",s);
    len=strlen(s);
    scanf("%d",&k);
    if((len+k)%2!=0&&len!=0) { index++;}
    while(index<len)
    {
        int mid=index+ (len+k-index)/2;
        for(i=0;mid+i<len;i++)
        {
            if(s[index+i]!=s[mid+i]) break;
        }
        if(mid+i>=len) {flag=0;break;}
        index+=2;
    }
    count1=len+k-index-flag;
    index=0;flag=2,k=0;
    if((len+k)%2!=0&&len!=0) { index++;}
    while(index<len)
    {
        int mid=index+ (len+k-index)/2;
        for(i=0;mid+i<len;i++)
        {
            if(s[index+i]!=s[mid+i]) break;
        }
        if(mid+i>=len) {flag=0;break;}
        index+=2;
    }
    count2=len+k-index-flag;
    if(count1<count2) count1=count2;
    printf("%d",count1);
return 0;
}


#include<stdio.h>
int main()
{
    int a,ac,b,bc,cc,c,n,i,days=0,j;
    scanf("%d %d %d",&a,&b,&c);

    for(j=1;j<8;j++)
    {
        n=0;
        ac=a;
        bc=b;
        cc=c;
        i=j;
        while(1)
        {

            if(i==1||i==4||i==7)
            {
                if(ac==0)break;
                ac--;
            }
            else if(i==2||i==6)
            {
                if(bc==0)break;
                bc--;
            }
            else
            {
                if(cc==0)break;
                cc--;
            }
            if(i==7)i=1;
            else i++;
            n++;
            //printf("%d %d %d\n",ac,bc,cc);
        }
        if(days<n)days=n;
    }
    printf("%d",days);
}


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

void countingCards(char *str){
    int count = 0;
    int i = 0;
    while(str[i] != '\0'){
        if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u'){
            count++;
        }
        else if(str[i] == '1' || str[i] == '3' || str[i] == '5' || str[i] == '7' || str[i] == '9'){
            count++;
        }
    }
    return;
}

int main() {
    char str[51];
    scanf("%s", str);
    countingCards(str);
    return 0;
}


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

#define MAX 100
#define MAX_VALUE 1000000000000000000L

typedef unsigned long long UINT64;

int maxIndex = 0;
UINT64 min = 0;
UINT64 arr[MAX] = {0, };

void getMinVal(char *num, int n, int index) {
    int i = 0;
    if (index > maxIndex) {
        return;
    }

    if (!*num) {
        UINT64 v = 0, pow = 1;
        for (i=index-1;i>=0;i--) {
            v += arr[i] * pow;
            pow *= n;
        }

        if (min == 0 || min > v) {
            min = v;
        }
    } else {
        int v = 0;
        char sub[MAX] = {0, }, *p = num;

        while (*p) {
            if (p == num && *p == '0') {
                arr[index] = 0;
                getMinVal(p + 1, n, index + 1);
                break;
            } else {
                sub[i++] = *p;
                v = atoi(sub);
                if (v >= n) {
                    break;
                }

                arr[index] = v;
                p++;
                getMinVal(p, n, index + 1);
            }
        }
    }
}

void setMaxIndex(int n) {
    UINT64 v = MAX_VALUE;
    while (v) {
        v /= n;
        maxIndex++;
    }
}

int main(void) {
    int n = 0;
    char num[MAX] = {0, };

    scanf("%d", &n);
    scanf("%s", num);

    setMaxIndex(n);
    getMinVal(num, n, 0);

    printf("%llu\n", min);

    return 0;
}


#include <stdio.h>

int Cnt[10];

int main()
{
    int table[] = {999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9};
    int n, reamin = 0, ans = 0;
    scanf("%d", &n);
    for(int i = 0; i < 9; ++i) {
        if(n + n - 1 >= table[i]) {
            reamin = table[i];
            break;
        }
    }
    if(reamin == 0) {
        printf("%d\n", (int)((long long)n * (n - 1) / 2));
        return 0;
    }
    for(int i = 0; i < 9; ++i) {
        int expect = (reamin + 1) * i + reamin;
        if(n + n - 1 >= expect) {
            if(expect <= n) {
                ans += expect / 2;
            } else {
                ans += n - expect / 2;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>

int main(){
	long long int i,n;
	scanf("%lld",&n);
	long long int temp=n*2;
	temp/=10;
	long long int m=0;
	long long int m10=1;
	while(temp>0){
		temp/=10;
		m++;
		m10*=10;
	}
	if(m==0){
		printf("%ld\n",(n*(n-1))/2);
		return 0;
	}
	long long int ans=0,val=0;
	for(i=1;i<9;i++){
		if(i*m10>2*n)break;
		if(n>=i*m10-1){
			ans+=((i*m10/2)-1);
//			val=((i*m10/2)-1);
//			printf("%d\n",val);
		}
		else{
			ans+=(n+1-(i*m10/2));
//			val=(n+1-(i*m10/2));
//			printf("%d\n",val);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define M	4167669	/* (23 choose 7) * 17 */
#define C	16
#define K	2000000000
#define T	7

int add(int a, int b) { return (long long) a + b < K ? a + b : K; }

void print(int k) {
	if (k == 0)
		return;
	print(k / C);
	printf("%c", k % C < 10 ? k % C + '0' : k % C - 10 + 'a');
}

int aaa[M][C + 1], m;

void branch(int *aa, int h) {
	int a, len;

	if (h == C) {
		for (len = 0; len <= C; len++) {
			aa[h] = len;
			memcpy(aaa[m++], aa, (C + 1) * sizeof *aa);
		}
		return;
	}
	for (a = h == 0 ? 0 : aa[h - 1]; a <= T; a++) {
		aa[h] = a;
		branch(aa, h + 1);
	}
}

int choose[C + T][C + T];

void init1() {
	int n, r;

	choose[0][0] = 1;
	for (n = 1; n < C + T; n++) {
		choose[n][0] = 1;
		for (r = 1; r <= n; r++)
			choose[n][r] = choose[n - 1][r - 1] + choose[n - 1][r];
	}
}

int idx(int *aa) {
	int h, a, sum;

	sum = 0;
	for (h = 0; h < C; h++)
		for (a = h == 0 ? 0 : aa[h - 1]; a < aa[h]; a++)
			sum += choose[C - h - 1 + T - a][T - a];
	return sum * (C + 1) + aa[C];
}

int dp[M];

void init2() {
	static int a_[C + 1], *aa = a_;
	int h, i, j, a, len;

	branch(aa, 0);
	for (i = 0; i < m; i++) {
		aa = aaa[i];
		len = aa[C];
		if (len == 0)
			dp[i] = 1;
		else
			for (h = 0; h < C; h++) {
				if (aa[h] == 0)
					continue;
				if (h == 0 || aa[h - 1] != aa[h]) {
					a = aa[h] - 1;
					j = i / (C + 1) - choose[C - h - 1 + T - a][T - a];
					if (h < C - 1)
						j += choose[C - h - 2 + T - a][T - a];
					j = j * (C + 1) + len - 1;
				}
				dp[i] = add(dp[i], dp[j]);
			}
	}
}

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int aa[C + 1], bb[C + 1];
	int k, t, h, i, first;

	scanf("%d%d", &k, &t);
	if (t >= 8) {
		print(k);
		printf("\n");
		return 0;
	}
	init1();
	init2();
	for (h = 0; h < C; h++)
		aa[h] = t;
	for (aa[C] = 1; ; aa[C]++) {
		int cnt = dp[idx(aa)];

		aa[0]--; aa[C]--;
		cnt -= dp[idx(aa)];
		aa[0]++; aa[C]++;
		if (k <= cnt)
			break;
		k -= cnt;
	}
	first = 1;
	while (aa[C]-- > 0) {
		for (h = first ? 1 : 0; h < C; h++) {
			memcpy(bb, aa, (C + 1) * sizeof *aa);
			if (bb[h] == 0)
				continue;
			bb[h]--;
			qsort(bb, C, sizeof *bb, compare);
			if (k > dp[i = idx(bb)]) {
				k -= dp[i];
				bb[h]++;
			} else {
				printf("%c", h < 10 ? h + '0' : h - 10 + 'a');
				aa[h]--;
				break;
			}
		}
		first = 0;
	}
	printf("\n");
	return 0;
}


#include<stdio.h>

int main()
{

int n,x,y;

scanf("%d%d%d",&num,&x,&y);
n=n/2;

if((x==n||x==n+1) && (y==n||y==n+1))
{
printf("NO");
}

else
{
printf("YES");
}
return(0);
}


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


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

int n;

int special(int x, int y) {
  long long xx = x, yy = y, nn = n; xx *= x; yy *= y; nn *= n;
  return xx + yy < nn;
}

int main(void) {
  int i, j, r = 0, s = 0;
  scanf("%d", &n);
  j = n;
  for (i = 0; i <= j; ++i) {
    while (!special(i, j)) --j;
    if (i < j) ++r;
    if (i == j) ++s;
  }
  r = 2*r + s; r += r - 1; r += r - 2;
  printf("%d\n", n == 0 ? 1 : n == 1 ? 4 : r);
  exit(EXIT_SUCCESS);
}


#include<stdio.h>

#define m 1000000007

long long power( long long a, long long b ) {
	long long x=a, y=b;
	long long ans = 1;
	while( y ) {
		if( y%2 )
			ans = (ans*x)%m;
		x = (x*x)%m;
		y /= 2;
	}
	return ans;
}

int main() {
	long long k, p;
	scanf("%lld%lld",&p, &k);
	if( k==0 )
		printf("%lld\n", power(p,p-1));
	if( k==1 )
		printf("%lld\n", power(p,p));
	long long ord = 1;

	for( ; k != 1; ++ord )
		k = (k*k)%p;

	printf("%lld\n", power(p,(p-1)/ord));
}


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

int main(){
    char word1[101],word2[101];
    int i,n,m,j,count,l=0;
    scanf("%s",word1);scanf("%s",word2);
    n=strlen(word1);m=strlen(word2);
    if(n>m){printf("1");l=1;}else if(n<m) {printf("-1");l=1;}

    if(l!=1){for(i=0;i<n;i++){
      //  for(j=0;j<m;j++){
            if(word1[i]==word2[i] || word1[i]==word2[i]+32 || word1[i]+32 ==word2[i]){}
            else if(word1[i]>word2[i]) return 1;
            else if(word1[i]<word2[i]) return -1;
       // }
    }
printf("0");}

return 0;}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i,j,a,b,year1,year2,c,d,month1,day1,month2,day2,counter=0,hold1;
	char string[10];
	int arr[139]={0};
	arr[100]=1;
	for(i=1;i<139;i++)
	{
		if(i%4==0)
			arr[i]=1;
	}
	int month[13];
	month[1]=31;
	month[2]=28;
	month[3]=31;
	month[4]=30;
	month[5]=31;
	month[6]=30;
	month[7]=31;
	month[8]=31;
	month[9]=30;
	month[10]=31;
	month[11]=30;
	month[12]=32;
	scanf("%s",string);
	year1=(string[0]-'0')*1000+(string[1]-'0')*100+(string[2]-'0')*10+(string[3]-'0');
	month1=(string[5]-'0')*10+(string[6]-'0');
	day1=(string[8]-'0')*10+(string[9]-'0');
	scanf("%s",string);
	year2=(string[0]-'0')*1000+(string[1]-'0')*100+(string[2]-'0')*10+(string[3]-'0');
	month2=(string[5]-'0')*10+(string[6]-'0');
	day2=(string[8]-'0')*10+(string[9]-'0');
	if(year1>year2)
	{
		hold1=year1;
		year1=year2;
		year2=hold1;
		hold1=month1;
		month1=month2;
		month2=hold1;
		hold1=day1;
		day1=day2;
		day2=hold1;
	}
	if(year2>=year1+1)
	{
		if(year2>year1+1)
		{
			for(j=(year1+1)-1900;j<year2-1900;j++)
			{
				if(arr[j]==1)
					counter+=366;
				else
					counter+=365;
			}
		}
		counter+=month[month1]-day1+1;
		if(month1==2 && arr[year1]==1)
			counter++;
		for(j=month1+1;j<13;j++)
		{
			counter+=month[j];
			if(j==2 && arr[year1-1900]==1)
				counter++;
		}
		counter+=day2;
		for(j=1;j<month2;j++)
		{
			counter+=month[j];
			if(j==2 && arr[year2-1900]==1)
				counter++;
		}

	}
	else if(year1==year2)
	{
		if(month1!=month2)
		{
			counter+=month[month1]-day1+1;
			if(month1==2 && arr[year1]==1)
				counter++;
			counter+=day2;
			for(j=month1+1;j<month2;j++)
			{
				counter+=month[j];
				if(arr[year1-1900]==1)
					counter++;
			}
		}
		else
		{
			if(day1!=day2)
				counter=counter+day2-day1+1;
			else
				counter=2;
		}

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


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

int odd_goldbach(int *prime, int n) {
    int i;
    for (i = 2; i <= n-i; i++) {
        if (prime[i] && prime[n-i]) {
            return 1;
        }
    }
    return 0;
}

int main(void) {
    int n, *prime, i, j;
    scanf("%d",&n);
    prime = (int*)malloc(sizeof(int)*(n+1));
    assert(prime);
    for (i = 2; i <= n; i++) {
        prime[i] = 1;
    }
    for (i = 2; i <= n; i++) {
        for (j = 2; prime[i] && i*j <= n; j++) {
            prime[i*j] = 0;
        }
    }
    if (prime[n]) {
        putchar('1');
    } else if (!(n%2) || odd_goldbach(prime,n)) {
        putchar('2');
    } else {
        putchar('3');
    }
    free(prime);
    return 0;
}


#include<stdio.h>
int main()
{
	int n,a,t[104],i,left,right,ans=0,flag1=0,flag2=0;
	scanf("%d%d",&n,&a);
	left=a-1;
	right=a-1;
	for(i=0;i<n;i++)
		scanf("%d",&t[i]);
	if(n==1)
	{
		if(t[0]==1)
			printf("1\n");
		else printf("0\n");
		return 0;
	}
	if(t[a-1]==1)
		ans++;
	while(left>=0 || right<n-1)
	{
		flag1=0;
		flag2=0;
		if(left>0)
		{
			left=left-1;
			flag1=1;
		}
		if(right<n-1)
		{
			right=right+1;
			flag2=1;
		}
		if(t[left]==1 && t[right]==1 && flag1==1 && flag2==1)
			ans=ans+2;
		else if(flag1==0 && flag2==1)
		{
			if(t[right]==1)
				ans=ans+1;
			left=left-1;
		}
		else if(flag2==0  && flag1==1 && t[left]==1)
		{
			ans++;
			left=left-1;
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include <stdio.h>
int main(){
    long long n,i;
    int flg=0;
    scanf("%lli",&n);
    if(n%2){
        for(i=3;i*i<=n;i++){
            if((n%i)==0){
                flg=1;
                break;
            }
        }
        if(flg==0)
        n = 0
        else
        n -= i;
        n = n/2;
        n++;
    }
    else n /= 2;
    printf("%lli\n",n);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i=0,j=i+1,c=0;
    scanf("%d",&n);
    char str[100];
    for(int i=0;i<n;i++)
    {
        scanf("%c",str[i]);
    }
   while(i<n-1 && j<n)
   {
       if(str[i]==str[j])
         c++;
    i++;
    j++;
   }
   printf("%d",c);
   return 0;
}


#include <stdio.h>
#include<string.h>
int main()
{
int i,j,k,n,t=0;
scanf("%ld\n%ld",&k,&n);
if(n%k==0)
for(i=k;i<=n;i*=k)
{
if(i==n)
{printf("YES\n%d",t);

return 0;
}t++;}
printf("NO");
return 0;
}


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

int main(void){
     int n,i,sum1=0,sum2=0;

     scanf("%d",&n);

     char a[n];

     scanf("%s",a);

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

          if(a[i]=='4'||a[i]=='7'){

               if(i< n/2)
                    sum1=sum1+a[i];
               else
                    sum2=sum2+a[i];
          }
          else{
               printf("NO");
               exit(1);
          }
     }
     if(sum1==sum2)
        printf("YES");
    else printf("NO");

    return 0;
}


#include<stdio.h>

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

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

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

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

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

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

return 0;

}


#include<stdio.h>

int main()
{
    int cn1, cn2, cn3, cn4;
    scanf("%d%d%d%d", &cn1, &cn2, &cn3, &cn4);
    if(cn1 == cn4 && (cn2 > 0 || cn3 == 0))
    return 1;
    return 0;
}


/* Problem: 779B - Weird Rounding */
/* Solver: Gusztav Szmolik */

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

int main ()
    {
    char n[12];
    unsigned short k;
    unsigned short ln;
    unsigned short cz;
    unsigned short i;

    if (scanf("%11s %hu",n,&k) != 2)
        return -1;
    ln = strlen (n);
    if (ln > 10)
        return -1;
    cz = 0;
    for (i = 0; i < ln; i++)
        {
        if (!isdigit(n[i]))
            return -1;
        if (n[i] == '0')
            cz++;
        }
    if (ln > 1 && n[0] == '0')
        return -1;
    if (ln == 10 && strcmp(n,"2000000000"))
        return -1;
    if (!cz)
        return -1;
    if (k < 1 || k > 9)
        return -1;
    if (k > cz)
        {
        printf ("%hu\n",ln-1);
        return 0;
        }
    cz = 0;
    for (i = 0; cz < k; i++)
        if (n[ln-1-i] == '0')
            cz++;
    printf ("%hu\n",i-k);
    return 0;
    }


#include<stdio.h>
int main(){
    int i,j,n,m,k,stock[81]={0},temp=0,count=0,ans = 0, a[81],check[81]={0};
    scanf("%d %d",&n ,&k);
    for(j=1;j<=n;j++)
        scanf("%d",&a[j]);
    stock[a[1]]++;
    ans++;
    count++;
    for(j=2;j<=n;j++){
        if(stock[a[j]] == 1) continue;
        if(count == k){
            for(i=0; i<81; i++)
                check[i] = 0;
            temp = count;
            for(i=j+1; i<=n; i++){
                if(temp == 1){
                    for(m=1; m<81; m++)
                        if(check[m] == 0 && stock[m]){
                            stock[m] = 0;
                            count--;
                            break;
                        }
                    break;
                }
                if(stock[a[i]] == 1 && check[a[i]] == 0){
                    temp--;
                    check[a[i]] = 1;
                }
            }
            if(temp!=1){
                for(m=1; m<81; m++)
                    if(check[m] == 0 && stock[m]){
                        stock[m] = 0;
                        count--;
                        break;
                    }
            }
        }
        stock[a[j]]++;
        count++;
        ans++;
        /*printf("%d\t",ans);
        for(i=0; i<81;i++)
            if(stock[i]) printf("%d ",i);
        printf("\n");*/
    }
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},time[81]={0},money=0,number=0,de=0,k=0,chose=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%d",&book[i]);
    for(i=0;i<n;i++)
    {
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=0;j<81;j++)
                time[j]=0;
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1 && time[book[j]]==0)
                {
                    time[book[j]]=1;
                    de=book[j];
                }
            }
            for(j=0;j<11;j++)
            {
                chose=0;
                if(now[j]==1)
                {
                    //but=now[j];
                    for(k=i;k<n;k++)
                    {
                        if(j==book[k])
                            chose=1;
                    }
                    if(chose==0)
                        de=j;
                }

            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}


#include<stdio.h>

typedef unsigned long long int uint64;
typedef unsigned char uint8;

uint8 findsum(uint64 x)
{
   uint8 sum=0;
   uint8 temp;
   while(x!=0)
   {
      temp = x%10;
      sum += temp;
      x= x/10;
   }
   return sum;
}

int main(void)
{
   uint64 x;
   uint64 maxsum=0,maxnum=0,sum;
   scanf("%llu",&x);
   for(int i=x;i>0;i--)
   {
      sum = findsum(i);
      if(sum > maxsum)
      {
         maxsum = sum;
         maxnum = i;
      }
   }

   printf("%llu",maxnum);
   return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string.h>
/*#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>

#include<algorithm>
#include<iterator>
#include<iostream>
#include<list>
#include<vector>*/
#define maxn 110

int main()
{
    char a[maxn];
    char *p;
    int n;
    int k[maxn];
    int flag;
    int i;
    while(scanf("%d",&n))

    {
        getchar();
        memset(k,0,sizeof(k));
        gets(a);
        p=a;
        i=0;

        flag=0;
        while(*p)
        {
            while(*p=='B')
            {   if(!flag)
                 i++;

                flag=1;
                k[i]++;
                p++;
            }
            p++;
            flag=0;
        }
        printf("%d\n",i);
        if(i)

        {for(int j=1;j<i;j++)
            printf("%d ",k[j]);
        printf("%d\n",k[i]);}
    }

}


#include<stdio.h>

int main()
{
long long int ar[10000];
long long int a,b,c,count=0;
long long k,n,i,j;
long long two=0,five=0;
scanf("%lld",&n);

for(i=5;;i++)
{
    five=0;
    for(j=5;j<=i;j=j+5)
    {
        k=j;
        while(k%5==0)
        {
            five++;
            k=k/5;
        }

    }
        if(five==n){ar[count]=i;count++;}
        if(five>n){break;}
}
printf("%lld\n",count);
for(i=0;i<count;i++)
{
    printf("%d ",ar[i]);
}
//main();
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
void main()
{
	int n,l,j,i,p,ctr=0,btr=0;
	int bk[n],bs[n],k[n];
	int h=0;

	printf("enter the n and l");
	scanf("%d%d",&n,&l);

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

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

	}

	for(i=0;i<l;i++)
	{
		btr=0;
		for(j=0;j<n;j++)
		{
			if(i+bs[j]>=l)
			k[j]=i+bs[j]-l;
			else
			k[j]=i+bs[j];
		ctr=0;
		for(p=0;p<n;p++)
		{
			if(k[j]==bk[p])
			ctr++;

		}
		if(ctr>0)
		{
		btr++;
		continue;
		}

		}
		if(btr==n)
		{

		printf("yes");

		break;
		}

	}

}


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

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

long long dpp[5002][5002];
int n , a , b , k ;

#define MOD 1000000007

void build(long long arr[] , long long rmq []){
	int i ;
	for(i = 1 ; i <= n ; i++){
		// cout << arr[i] << " " ;
		int index = i ;
		while(index <= n){
			rmq[index] += arr[i] ;
			index += (index & -index);
		}
	}
	//cout << endl ;
}

long long query(long long rmq [] , int to){
	long long ret = 0 ;
	// cout << "to : " << to << " : "  ;
	while(to > 0){
		ret += rmq[to];
		ret %= MOD ;
		to -= (to & -to);
	}
	//cout <<ret << endl ;
	return ret ;
}

int main(){
	scanf("%d%d%d%d" , & n , &a , &b , &k);
	int i ;
	for(i = 1 ; i <= n ; i ++){
		dpp[0][i] = 1 ;
	}
	dpp[0][b] = 0 ;
	for(i =  1 ; i <= k ; i++){
		// cout << i << " : " << endl ;
		long long rmq [10003] ={0};
		build(dpp[i-1] , rmq);
		int j ;
		for(j = 1 ; j <= n; j++){
			if(j == b)
				continue ;
			int diff = abs(b - j) - 1;
			dpp[i][j] = query(rmq , min(n , j + diff));
			dpp[i][j] -= query(rmq , max(1 , j - diff) -1 );
			dpp[i][j] -= dpp[i-1][j];
			dpp[i][j] %= MOD ;
			dpp[i][j] += MOD ;
			dpp[i][j] %= MOD ;
		}
		// cout << i << " :  => " << endl ;
		// for(int j = 1 ; j <= n ; j++){
		// 	cout << dpp[i][j] << " ";
		// }
		//cout << endl ;
	}
	printf("%d" , dpp[k][a]);
	return 0 ;
}


#include <stdio.h>

int main() {
  int in,i;
  long long x,go;
  scanf("%d",&in);
  x=in<0?-in:in;
  if(x==0) { i=0; goto done; }
  for(go=0,i=1;;i++) {
    go+=i;
    if(go==x) break;
    if(go>x && (go-x)%2==0 && (go-x)/2<=i) break;
  }
done:
  printf("%d\n",i);
  return 0;
}


#include<stdio.h>
int main()
{
    int a[5][5],i,j,ans=0;
    for(i=0;i<5;i++)
     for(j=0;j<5;j++)
     {
         scanf("%d",a[i][j]);
         if(a[i][j]==1)
          break;
     }
     if(i>=3)
        ans=ans+i-3;
     if(i<3)
        ans=ans+3-i;
     if(j>=3)
        ans=ans+j-3;
     if(j<3)
        ans=ans+3-j;
     printf("%d",ans);
}


#include<stdio.h>
int main()
{
    int i,l,count=0;
    char pos[100];
    scanf("%s",pos);
    l=strlen(pos);
    for(i=0;i<l;i++)
    {
        while(pos[i]==pos[i+1])
        {
        count++;
        if(count>=7)
        printf("YES");
        }
    }
        if(count<7)
        printf("NO");

}


#include<stdio.h>
int main()
{
	int suma,sumb;
	char f;
	int i,j;
	int arr[8][8];
	int k=1;
	for (i=1;i<=8;i++)
	{
		for (j=1;j<=8;j++)
		{
			scanf("%c",&arr[i][j]);
			if (k%8==0)
			{	scanf("%c",&f);
				k=1;
			}
			else
				k++;

			if (arr[i][j]=='Q')
				suma=suma+9;
			if (arr[i][j]=='R')
				suma=suma+5;
			if (arr[i][j]=='B')
				suma=suma+3;
			if (arr[i][j]=='N')
				suma=suma+3;
			if (arr[i][j]=='P')
				suma=suma+1;
			if (arr[i][j]=='q')
				sumb=sumb+9;
			if (arr[i][j]=='r')
				sumb=sumb+5;
			if (arr[i][j]=='b')
				sumb=sumb+3;
			if (arr[i][j]=='n')
				sumb=sumb+3;
			if (arr[i][j]=='p')
				sumb=sumb+1;
			else
				;

		}
	}
	if (suma>sumb)
		printf("White");
	if (suma==sumb)
		printf("Draw");
	if (suma<sumb)
		printf("Black");
}


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

int main()
{
    int i,size,k=0;
    int longestWordOutsideParanthesis=0;
    int numberOfWordsInsideParanthesis=0;
    int longest[200];
    int foundLetter=0;
    int cont=0;

    scanf("%d",&size);

    char str[size];

    scanf("%s",&str);

    for(i=0; str[i]!='\0';)
    {
        if(str[i]=='_')
        {
            i++;
            cont=0;
        }
        else if(str[i]=='(')
        {
            cont=0;
            i++;
            foundLetter=0;

            while(str[i]!=')')
            {
                if(str[i]=='_')
                {
                    foundLetter=0;
                }

                else
                {
                    if(foundLetter==0)
                    {
                        numberOfWordsInsideParanthesis++;
                    }

                    foundLetter=1;
                }
                i++;

            }
        }
        else if(str[i]==')')
            i++;

        else
        {
            cont++;
            longest[k]=cont;
            k++;
            i++;

        }

    }

    for(i=0; i<k; i++)
    {
        if(longest[i]>longestWordOutsideParanthesis)
            longestWordOutsideParanthesis=longest[i];
    }

    printf("%d ",longestWordOutsideParanthesis);
    printf("%d",numberOfWordsInsideParanthesis);

    return 0;
}


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

int main(void){
	int *arr,num,i,ctr=0,j;

	scanf("%d",&num);
	arr = (int*)malloc(sizeof(int));

	for(i=num;i>0;i--){
		if(num%i == 0){
			arr[ctr] = i;
			ctr++;
		}
	}
	for(i=0;i<=ctr;i++){
		if(arr[i]!=-1){
			for(j=i+1;j<ctr;j++){
	          if(arr[i]%arr[j] != 0){
			      arr[j] = -1;
	          }
			}
		}
	}

	for(i=0;i<ctr;i++){
		if(arr[i]!=-1){
		printf("%d ",arr[i]);
		}
	}
}


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

int sum(int *arr, int size) {
    int total = 0;

    for (int i = 0; i < size; i++) {
        total += arr[i];
    }

    return total;
}

int main(int argc, char **argv)
{
    int vs, es; // vs vertexes es edges
    scanf("%d %d", &vs, &es);

	int graph[vs+1][vs+1];
    for (int i = 0; i <= vs; i++) {
        memset(graph[i], 0, sizeof(graph[i]));
    }

    int v1, v2;
    for (int i = 0; i < es; i++) {
        scanf("%d %d", &v1, &v2);
        graph[v1][v2] = 1;
        graph[v2][v1] = 1;
    }

    char letters[vs+10];
    memset(letters, '-', sizeof(letters));
    letters[vs+1] = '\0';

    for (int i = 1; i <= vs; i++) {
        if (sum(graph[i]+1, vs) == vs - 1) {
            letters[i] = 'b';
        }
    }

    int stack[100*1000];
    int size = -1, v;
    int qntA = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            stack[++size] = i;
            while (size > -1) {
                v = stack[size--];
                letters[v] = 'a';
                qntA += 1;
                for (int j = 1; j <= vs; j++) {
                    if (graph[v][j] == 1 && letters[j] == '-') {
                        stack[++size] = j;
                    }
                }
            }
            break;
        }
    }

    int qntC = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            letters[i] = 'c';
            qntC += 1;
        }
    }

    //verificando se A esta correto
    int count;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'a') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'a') {
                count += 1;
            }
        }
        if (qntA - 1 != count) {
            a = 0;
            break;
        }
    }

    // verificando C
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'c') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'c') {
                count += 1;
            }
        }
        if (qntC - 1 != count) {
            c = 0;
            break;
        }
    }

    if (a && c) {
        printf("Yes\n%s", letters+1);
    } else {
        printf("No", letters+1);
    }

	return 0;
}


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

int sum(int *arr, int size) {
    int total = 0;

    for (int i = 0; i < size; i++) {
        total += arr[i];
    }

    return total;
}

int main(int argc, char **argv)
{
    int vs, es; // vs vertexes es edges
    scanf("%d %d", &vs, &es);

	int graph[vs+1][vs+1];
    for (int i = 0; i <= vs; i++) {
        memset(graph[i], 0, sizeof(graph[i]));
    }

    int v1, v2;
    for (int i = 0; i < es; i++) {
        scanf("%d %d", &v1, &v2);

        graph[v1][v2] = 1;
        graph[v2][v1] = 1;
    }

    char letters[vs+10];
    memset(letters, '-', sizeof(letters));
    letters[vs+1] = '\0';

    for (int i = 1; i <= vs; i++) {
        if (sum(graph[i]+1, vs) == vs - 1) {
            letters[i] = 'b';
        }
    }

    int stack[100*1000];
    int size = -1, v;
    int qntA = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            stack[++size] = i;
            while (size > -1) {
                v = stack[size--];
                if (letters[v] == '-') {
	                letters[v] = 'a';
	                qntA += 1;
	                for (int j = 1; j <= vs; j++) {
	                    if (graph[v][j] == 1 && letters[j] == '-') {
	                        stack[++size] = j;
	                    }
	                }
                }
            }
            break;
        }
    }

    int qntC = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            letters[i] = 'c';
            qntC += 1;
        }
    }

    //verificando se A esta correto
    int a = 1, c = 1;
    int count;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'a') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'a') {
                count += 1;
            }
        }
        if (qntA - 1 != count) {
            a = 0;
            break;
        }
    }

    // verificando C
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'c') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'c') {
                count += 1;
            }
        }
        if (qntC - 1 != count) {
            c = 0;
            break;
        }
    }

    if (a && c) {
        printf("Yes\n%s", letters+1);
    } else {
        printf("No", letters+1);
    }

	return 0;
}


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

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

    for(int i = 0; i < k; i++){
        if(n % 10 == 0){
            n = n/10;
        }
        else{
            n = n - 1;
        }
    }

    printf("%d", n);
}


#include<stdio.h>
int main()
{
    int n,a,b,c,sum=0,min,found=0;
    scanf("%d\n%d\n%d\n%d\n",&n,&a,&b,&c);
    min=a;
    if(b<a)
    min=b;
    if(c<min)
    min=c;

    else if(min==c)
    {
        if(n==1)
        {sum=0;
        break;}
        if(a<b)
        sum=a+c*(n-2);
        else
        sum=b+c*(n-2);
    }
    else if(min==a)
    {
        sum=a*(n-1);
    }
    else if(min==b)
    sum=b*(n-1);

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


/*
Project name : hamburgar
Created on : Wed Dec 11 11:58:38 IST 2013
http://codeforces.com/problemset/problem/371/C

*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int debug=0;
typedef long long int lld;
int kb,nb,pb,ks,ns,ps,kc,nc,pc;
lld r;
lld getCost(lld n){
    lld ab=(n*kb-nb);ab=ab>0?ab:0;
    lld as=(n*ks-ns);as=as>0?as:0;
    lld ac=(n*kc-nc);ac=ac>0?ac:0;
    if(debug){
        printf("cost for : n=%lld \n",n);
        printf("cost of b : %lld\n",ab*pb);
        printf("cost of s : %lld\n",as*ps);
        printf("cost of c : %lld\n",ac*pc);
        printf("\n\n");
    }
    return ab*pb+as*ps+ac*pc;
}
int main(int argc , char **argv)
{
    if(argc>1 && strcmp(argv[1],"DEBUG")==0) debug=1;
    char str[101];
    scanf("%s",str);
    int i;
    kb=0;ks=0;kc=0;
    for(i=0;i<strlen(str);++i){
        switch(str[i]){
        case 'B':
            ++kb;
            break;
        case 'S':
            ++ks;
            break;
        case 'C':
            ++kc;
            break;
        }
    }
    scanf("%d %d %d",&nb,&ns,&nc);
    scanf("%d %d %d",&pb,&ps,&pc);
    scanf("%lld",&r);
    if(debug){
        printf("kb=%d ks=%d kc=%d\n",kb,ks,kc);
        printf("nb=%d ns=%d nc=%d\n",nb,ns,nc);
        printf("pb=%d ps=%d pc=%d\n",pb,ps,pc);
        printf("r=%lld\n",r);
    }
    lld n=1;
    while(getCost(n)<=r)n*=2;
    lld start=n/2,end=n,mid=(start+end)/2,cost;
    while(end-start>1){
        cost=getCost(mid);
        if(debug)printf("start=%lld , end=%lld , cost=%lld\n",start,end,cost);
        if(cost>r)end=mid;
        else if(cost<r) start=mid;
        else break;
        mid=(start+end)/2;
    }
    if(cost==r)printf("%lld\n",mid);
    else printf("%lld\n",start);
    return 0;
}
/*
Project name : hamburgar
Created on : Wed Dec 11 11:58:38 IST 2013
http://codeforces.com/problemset/problem/371/C

*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int debug=0;
typedef long long int lld;
int kb,nb,pb,ks,ns,ps,kc,nc,pc;
lld r;
lld getCost(lld n){
    lld ab=(n*kb-nb);ab=ab>0?ab:0;
    lld as=(n*ks-ns);as=as>0?as:0;
    lld ac=(n*kc-nc);ac=ac>0?ac:0;
    if(debug){
        printf("cost for : n=%lld \n",n);
        printf("cost of b : %lld\n",ab*pb);
        printf("cost of s : %lld\n",as*ps);
        printf("cost of c : %lld\n",ac*pc);
        printf("\n\n");
    }
    return ab*pb+as*ps+ac*pc;
}
int main(int argc , char **argv)
{
    if(argc>1 && strcmp(argv[1],"DEBUG")==0) debug=1;
    char str[101];
    scanf("%s",str);
    int i;
    kb=0;ks=0;kc=0;
    for(i=0;i<strlen(str);++i){
        switch(str[i]){
        case 'B':
            ++kb;
            break;
        case 'S':
            ++ks;
            break;
        case 'C':
            ++kc;
            break;
        }
    }
    scanf("%d %d %d",&nb,&ns,&nc);
    scanf("%d %d %d",&pb,&ps,&pc);
    scanf("%lld",&r);
    if(debug){
        printf("kb=%d ks=%d kc=%d\n",kb,ks,kc);
        printf("nb=%d ns=%d nc=%d\n",nb,ns,nc);
        printf("pb=%d ps=%d pc=%d\n",pb,ps,pc);
        printf("r=%lld\n",r);
    }
    lld n=1;
    while(getCost(n)<=r)n*=2;
    lld start=n/2,end=n,mid=(start+end)/2,cost;
    while(end-start>1){
        cost=getCost(mid);
        if(debug)printf("start=%lld , end=%lld , cost=%lld\n",start,end,cost);
        if(cost>r)end=mid;
        else if(cost<r) start=mid;
        else break;
        mid=(start+end)/2;
    }
    if(cost==r)printf("%lld\n",mid);
    else printf("%lld\n",start);
    return 0;
}


#include <stdio.h>
char a;
int i;
unsigned long long n ,n1,n2,n3,c1,c2,c3, min,max,mid , b ,c ,s ,temp=0;
int main()
{
    while((a=getchar())!='\n'){
        if(a=='b') b++;
        if(a=='c') c++;
        if(a=='s') s++;
    }
    scanf("%llu%llu%llu%llu%llu%llu%llu",&n1,&n2,&n3,&c1,&c2,&c3,&n);
    min=0;
    max=2000000000;
    while(max>=min){
        mid=(min+max+1)/2;
        if(mid*b>n1)
            temp+=(mid*b-n1)*c1;
        if(mid*c>n3)
            temp+=(mid*c-n3)*c3;
        if(mid*s>n2)
            temp+=(mid*s-n2)*c2;
        if(n>temp)min=mid;
        else max=mid-1;
    }
    printf("%llu",min);
	return 0;
}


//324B.c
#include<stdio.h>
#include<math.h>
int main()
{
    int n,i,number,total,extra,final;
    scanf("%d",&n);

    number=3*n;

    total=pow(3,number);

    //calcualting when = 6

    extra= pow(7,n);

    final = total-extra;
    divisor=pow(10,9)+7;
    final=final%(divisor);

    printf("%d",final);

    return 0;
}


#include<stdio.h>
#include<math.h>
int main(void){
    int n
    long long int p,w;
    scanf("%d",&n);
    p=27;
    w=7;
    for(int i=1;i<n;i++){
        p = (p*27)%1000000007;
        w = (w*7)%1000000007;
    }
    if(p>w) printf("%d",p-w);
    else printf("-1");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define INF 1000000000

int a[500005];
int num;
int bs(int v)
{
    int left=1,right=num;
    while(left<=right)
    {
        int m=(left+right)/2;
        if(a[m]==v)return m;
        else if(a[m]>v)right=m-1;
        else left=m+1;
    }
    return -1;
}
int main()
{
    int i;
    int n;
    for(i=1;i*(i+1)/2<=INF;i++)
    {
        a[i]=i*(i+1)/2;
    }
    num=i-1;
    scanf("%d",&n);
    if(n>a[i-1])
    {
        printf("NO\n");
        return 0;
    }
    for(i=1;i<=n;i++)
    {
        int m=bs(n-a[i]);
        if(m!=-1)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


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

int a[50005],num;
int bs(int v)
{
    int left=1,right=num;
    while(left<=right)
    {
        int m=(left<=right)
        if(a[m]==v)return 1;
        else if(a[m]>v)right=m-1;
        else left=m+1;
    }
    return 0;
}
int main()
{
    int i,n;
    for(i=1;i*(i+1)/2<=1000000000;i++)
    {
        a[i]=i*(i+1)/2;
    }
    num=i-1;
    scanf("%d",&n);
    for(i=1;i<=num;i++)
    {
        if(bs(n-a[i]))
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstdlib>
#define f(x) (x*(x+1))/2
using namespace std;
int main()
{int f=0;
long long n,i=0,j=0;
cin>>n;
for(i=1;f(i)<=n;i++)
{
for(j=i;(f(i)+f(j))<=n;j++)
{if(f(i)+f(j)==n)
{printf("YES\n");
return 0;
}
}
}
printf("NO\n");
return 0;
}


#include<stdio.h>

#include<string.h>

int main()
{
	char array[100];
	int c,x=0,y=0,i;

	scanf("%d",&array);
    for(i=0;(i+1)!=NULL;i++)
    {
		if ( array[i]!= 'a' && array[i]!= 'e'&& array[i]!= 'i'&&array[i]!= 'o'&&array[i]!= 'u'&& array[i]!= 'n')
       { x=1;}

		if ( array[i+1]!= 'a' && array[i+1]!= 'e'&& array[i+1]!= 'i'&&array[i+1]!= 'o'&&array[i+1]!= 'u'&& array[i+1]!= 'n')
       { y=1;}

        if(x==1&&y==1)
        {
        printf("not");}
        else
        {printf("yes");}

        x=0;
        y=0;
         }

		return 0;
	}

/*
Input: Enter a string
This program is easy 2 understand
*/


/* .................... compiled by alankar....................
*/

//......................SHORTCUTS..............................

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

#define pi 3.14159265358979323846  //float type
#define MAX 100000  //for rmq
#define SQRTMAX 317   //for rmq
//#define gc getchar_unlocked

#define FOR(i,a,b) for(i=(a);i<(b);i++)

//only for +ve and single terms
#define s(x) scanf("%d",&x);
#define sl(x) scanf("%llu",&x);
#define p(x) printf("%d",x);
#define pl(x) printf("%llu\n",x);
//..........................................................

typedef long long int ll;
const ll MOD=1000000007;

//returns int and +ve numbers

/*inline int inp(){
    int n=0;
    char c;
    c=gc();
    while(c<'0' || c>'9'){
        c=gc();
    }
    while(c>='0' && c<='9'){
        n=(n<<3)+(n<<1)+c-'0';
        c=gc();
    }
    return n;
}
*/
//...................................

//power with mod........long long int
 ll power(ll a,ll b,ll mod){
      if(b==0)
            return 1;
      ll temp=power(a,b/2,mod);
      temp=(temp*temp)%mod;
      if(b&1)
            temp=(temp*a)%mod;
      return temp;
}

 //power without mod........ int
int pwr(int a,int b){
      if(b==0)
            return 1;
      int temp=pwr(a,b/2);
      temp=(temp*temp);
      if(b&1)
            temp=(temp*a);
      return temp;
}
 // .....long long int
ll gcd(ll a,ll b){
      return b==0?a:gcd(b,a%b);
}
 //......long long int
ll lcm(ll a,ll b){
      return (a/gcd(a,b))*b;
}
 //......long long int with mod
ll modularInverse(ll a,ll m){
      return power(a,m-2,m);
}

 //only for int
//inline int min(int a,int b) { return a<b? a : b; }
//inline int max(int a,int b) { return a>b? a : b; }

//normal compare func on integers //for qsort(name,size,sizeof(type),compare)
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
//.......................................................

//segment tree
//not template but how to use ST
//for minimum element
/*
long long s[400000];
long long a[1000000];
int create(long long b,long long e,long long n)
{
    if(b==e)
    {
        s[n]=a[b];
    }
    else
        {
            create(b,(b+e)/2,2*n+1);
            create((b+e)/2+1,e,2*n+2);
            s[n]=s[2*n+1]<s[2*n+2]?s[2*n+1]:s[2*n+2];
        }
    return 0;
}

//for finding minimum element b/w l and r
long long messi(long long b,long long e,long long l,long long r,long long n)
{
    long long i,j;
    if(e<l||b>r)
    {
        return 100000001;
    }
    if(b>=l&&e<=r)
    {
        return s[n];
    }
    i=messi(b,(b+e)/2,l,r,2*n+1);
    j=messi((b+e)/2+1,e,l,r,2*n+2);
    return i<j?i:j;
}
*/
//............................................................................
//range minimam query
//for mim and max number
/*

//preprocess create the min array

long min[SQRTMAX], max[SQRTMAX], b[MAX];
int size, n;

void preProcess(int n){
    int i=0, j=0, k=0;
    long minimum, maximum;

    size = sqrt(n);
    //printf("size = %d\n",size);
    while(j<size){
        minimum = maximum = b[i];
        for(k=0 ; k<size ; k++){
            if(minimum>b[i])
                minimum = b[i];
            if(maximum<b[i])
                maximum = b[i];
            i++;
        }
        min[j] = minimum;
        max[j] = maximum;
        j++;
    }
}

long findMin(int l, int r){
    int j, j2;
    long minimum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(minimum > b[l]){
            minimum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(minimum > min[j])
            minimum = min[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(minimum > b[l]){
            minimum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return minimum;
}

//finding max value
long findMax(int l, int r){
    int j, j2;
    long maximum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(maximum < b[l]){
            maximum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(maximum < max[j])
            maximum = max[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(maximum < b[l]){
            maximum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return maximum;
}
*/

//...........................................END OF TEMPLATE.................................................................
int main()
{ int i,j,k,t,m,s,a[101],b[101];

  s(m)
  s(s)
  j=s;
  if(s==0)
    printf("-1 -1");
  else if(s>(m*9))
    printf("-1 -1");
  else
  {
      i=0;
      while(s>=9)
      {
          a[i]=9;
          i++;
          s=s-9;
      }
      if(i<m && s)
      {
          a[i]=s;
          i++;
          s=0;
      }
      while(i<m)
        a[i]=0;
      i=m-1;
      while(j>9)
      {b[i]=9;
          i--;
          j=j-9;

      }
       if(i>0 && j)
      {
          b[i]=j-1;
          i--;
          j=1;
      }
      while(i>0)
      {
          b[i]=0;
          i--;
      }
      b[0]=j;

        FOR(i,0,m)
  p(b[i])
  printf(" ");
  FOR(i,0,m)
  p(a[i])
  }

    return 0;
}


#include<stdio.h>
int main()
{
int x,y,z;
int x1,yy,z1;
int a[7];
int i;
    scanf("%d%d%d",&x,&y,&z);
    scanf("%d%d%d",&x1,&yy,&z1);
    for i=1;i<=6;i++) scanf("%d",&a[i]);

    int ans=0;
    if (y<0) ans+=a[1];
    if (y>yy) ans+=a[2];
    if (z<0) ans+=a[3];
    if (z>z1) ans+=a[4];
    if (x<0) ans+=a[5];
    if (x>x1) ans+=a[6];
    printf("%d\n",ans);

    return 0;
}


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

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

void soultion()
{
    int n = 0;
    scanf("%d", &n);
    int *arr = calloc(sizeof(n),sizeof(int));

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

    qsort(arr, n, sizeof(int), cmpfunc);

    for(int i = 0; i < n;i++)
        printf("%d ",arr[i]);

    free(arr);

    printf("\n");
}

int main(int argc, const char *argv[])
{
    while (1)
        soultion();

    return 0;
}


//
//  main.c
//  Infinite Sequence
//
//  Created by Shubham Swain  on 24/05/16.
//  Copyright © 2016 Swain. All rights reserved.
//

#include <stdio.h>

int main() {

    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(c==0)
        if (a==b)
            printf("YES\n");
        else printf("NO\n");
    else
        if(b<a && c>0)
            printf("NO\n");
        if(b>a && c<0)
            printf("NO\n");
        if((b-a)%c==0)
            printf("YES\n");
}


#include<stdio.h>
int main()
{
	int a,b,c;
	int i=0,j=0;
	scanf("%d%d%d",&a,&b,&c);
	for(i=0;i<=100000;i++)
	{
		for(j=0;j<=100000;j++)
		{
			if(i*a+b*j==c)
			{
				printf("Yes");
				return 0;
			}

		}
	}
	printf("No");
	return 0;
}


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

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

int main() {
	char s[101];
	scanf("%s\n",s);
	int i,m,l=strlen(s);
	char *x[l],*p,*q;
	p=s;
	while (*p) {
		x[p-s]=p;
		p++;
	}
	qsort(x,l+1,sizeof *x,cmp);
	m=0;
	for (i=1;i<l;i++) {
		for (p=x[i],q=x[i-1];*p==*q;p++,q++) ;
		if (p-x[i]>m) m=p-x[i];
	}
	printf("%d\n",m);
	return 0;
}


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

int main () {

    uint64_t n;
    scanf("%"SCNu64, &n);

    if (n % 2 == 0) {
        printf("%"PRIu64i"\n", n / 2);
    }
    else {
        uint64_t j = 3;
        for ( ; j * j <= n; j += 2) {
            if (n % j == 0) {
                printf("%"PRIu64"\n", (1 + (n - j) / 2));
                n = 1;
                break;
            }
        }
        if (n > 1) {
            putchar('1');
            putchar("\n");
        }
    }

    return 0;
}
~
~


#include<stdio.h>
int main()
{
    long long int n,n1,i,j=2,flag=0,a[10000];

    scanf("%lld",&n);

    a[0]=2;

    long long int count=0;

    while(1){
        if(n%2!=0){
            for(i=2;i<=n;i++){
                flag=0;
                for(j=2;j<=i/2;j++){
                    if(i%j==0){
                        flag=1;
                        break;
                    }
                }

                if(flag==0){
                    if(n%i==0){
                        n1=n-i;
                        break;
                    }
                }
            }

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

        if(n==0) break;
    }
    printf("%lld",count);

}


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

int main()
{
    int n,a,b;
    scanf("%d",&n);
    printf("%d %d",n/36,n%36/3)
    return 0;
}


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

int main()
{

	int n;
	int feet;
	int inch;

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

		scanf("%d", &n);

		feet = n / 36;
		inch = n % 36;

		inch = (inch + 1 )/3;

		if (inch == 12)
		{
			feet++;
			inch = 0;
		}
		printf("%d %d\n", foot, inch);

	return 0;
}


#include <stdio.h>
using namespace std;

main() {
    int h, m, a;
    scanf("%d:%d%d", &h, &m, &a);
    m += a; h += m / 60; m %= 60; h %= 24;
    if (h < 10) printf("0");printf("%d:", h);
    if (m < 10) printf("0");printf("%d ", m);
}


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

typedef long long int lli;

#define TRUE         (1==1)
#define FALSE        (!(TRUE))
#define in32(x)      scanf("%d", &(x))
#define in64(x)      scanf("%I64d", &(x))
#define instr(x)     scanf("%s", (x))
#define out32(x)     printf("%d\n", (x))
#define out64(x)     printf("%I64d\n", (x))
#define outstr(x)    printf("%s\n", (x))
#define max(a,b)     ((a)<(b))?(b):(a)
#define min(a,b)     ((a)>(b))?(b):(a)
#define abs(a)       ((a)<0)?(-(a)):(a)
#define fo3(i,a,b)   for(i=(int)(a);i<=(int)(b);i++)
#define of3(i,a,b)   for(i=(int)(a);i>=(int)(b);i--)

#define MOD    998244353
#define MAX    5005
#define SENT   -1

typedef struct Pair {
    int fi, se;
} Pair;

int comp(Pair * f, Pair * s) {
    return (f->fi - s->fi);
}

void sort(Pair ** arr, int size) { // CHANGE THIS
    int i;
    if (size < 6) {
        int nSize = 0;
        int s = size;
        while (size != 0) {
            nSize = 0;
            for (i = 0; i < size - 1; i++)
                if (comp(arr[i], arr[i+1]) > 0) { // CHANGE THIS
                    Pair * tmp = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = tmp;
                    nSize = i+1;
                }
            size = nSize;
        }
        return;
    }
    Pair ** tmp = (Pair **)calloc(size, sizeof(Pair *)); // CHANGE THIS
    int lSize = (size >> 1);
    int rSize = size - lSize;
    sort(arr, lSize); sort(arr + lSize, rSize);
    int lPtr = 0, rPtr = 0;
    int ptr = 0;
    while (ptr != size) {
        if (lPtr == lSize)
            tmp[ptr] = arr[lSize + (rPtr++)];
        else if (rPtr == rSize || comp(arr[lPtr], arr[lSize + rPtr]) <= 0) // CHANGE THIS
            tmp[ptr] = arr[lPtr++];
        else
            tmp[ptr] = arr[lSize + (rPtr++)];
        ptr++;
    }
    for (i = 0; i < size; i++)
        arr[i] = tmp[i];
    free(tmp);
}

int main(void) {
    int i, n, m;
    in32(n);
    in32(m);
    int need[n];
    fo3(i,0,n-1)
        in32(need[i]);
    Pair ** p = calloc(m, sizeof(Pair*));
    fo3(i,0,m-1) {
        p[i] = calloc(1,sizeof(Pair));
        in32(p[i]->fi);
        in32(p[i]->se);
    }
    sort(p,m);
    lli pos = 2000000, min = 0, max = 2000000 - 1;
    int have[n];
    while (min <= max) {
        lli mid = (min + max) >> 1;
        fo3(i,0,n-1)
            have[i] = 0;
        lli spent = 0;
        lli maxDay = mid;
        of3(i,m-1,0) {
            int day = p[i]->fi;
            int ind = p[i]->se-1;
            int miss = need[ind] - have[ind];
            if (maxDay > day)
                maxDay = day;
            int buy = miss;
            if (buy > maxDay)
                buy = maxDay;
            have[ind] += buy;
            maxDay -= buy;
            spent += buy;
        }
        fo3(i,0,n-1)
            spent += ((need[i] - have[i])<<1);
        if (spent <= mid) {
            pos = mid;
            max = mid - 1;
        } else
            min = mid + 1;
    }
    out64(pos);
    return 0;
}